File: TextureSaverWebP.cpp

package info (click to toggle)
jazz2-native 3.5.0-1
  • links: PTS, VCS
  • area: contrib
  • in suites:
  • size: 16,836 kB
  • sloc: cpp: 172,557; xml: 113; python: 36; makefile: 5; sh: 2
file content (83 lines) | stat: -rw-r--r-- 3,119 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//#include <webp/encode.h>
//#include "common_macros.h"
//#include "TextureSaverWebP.h"
//#include "IFile.h"
//
//namespace nCine {
//
/////////////////////////////////////////////////////////////
//// PUBLIC FUNCTIONS
/////////////////////////////////////////////////////////////
//
//bool TextureSaverWebP::saveToFile(const Properties &properties, const char *filename)
//{
//	return saveToFile(properties, WebPProperties(), IFileStream::createFileHandle(filename));
//}
//
//bool TextureSaverWebP::saveToFile(const Properties &properties, std::unique_ptr<IFile> fileHandle)
//{
//	return saveToFile(properties, WebPProperties(), std::move(fileHandle));
//}
//
//bool TextureSaverWebP::saveToFile(const Properties &properties, const WebPProperties &webpProperties, const char *filename)
//{
//	return saveToFile(properties, webpProperties, IFileStream::createFileHandle(filename));
//}
//
//bool TextureSaverWebP::saveToFile(const Properties &properties, const WebPProperties &webpProperties, std::unique_ptr<IFile> fileHandle)
//{
//	//FATAL_ASSERT(properties.width > 0);
//	//FATAL_ASSERT(properties.height > 0);
//	//FATAL_ASSERT_MSG(properties.width <= 16383, "Image width exceeds WebP maximum pixel dimensions");
//	//FATAL_ASSERT_MSG(properties.height <= 16383, "Image height exceeds WebP maximum pixel dimensions");
//	//FATAL_ASSERT(properties.pixels != nullptr);
//	//ASSERT(properties.format == Format::RGB8 || properties.format == Format::RGBA8);
//
//	LOGI("Saving \"{}\"", fileHandle->filename());
//	if (fileHandle->IsValid() == false)
//		return false;
//
//	// Flip pixels data vertically if the corresponding flag is true
//	std::unique_ptr<unsigned char[]> flippedPixels;
//	if (properties.verticalFlip)
//	{
//		flippedPixels = std::make_unique<unsigned char[]>(dataSize(properties));
//		flipPixels(properties, flippedPixels.get());
//	}
//	void *texturePixels = properties.verticalFlip ? flippedPixels.get() : properties.pixels;
//
//	// Using the WebP Simple Encoding API
//	const uint8_t *pixels = static_cast<uint8_t *>(texturePixels);
//	uint8_t *output = nullptr;
//	size_t bytesWritten = 0;
//	switch (properties.format)
//	{
//		default:
//		case Format::RGB8:
//		{
//			if (webpProperties.lossless)
//				bytesWritten = WebPEncodeLosslessRGB(pixels, properties.width, properties.height, properties.width * bpp(properties.format), &output);
//			else
//				bytesWritten = WebPEncodeRGB(pixels, properties.width, properties.height, properties.width * bpp(properties.format), webpProperties.quality, &output);
//			break;
//		}
//		case Format::RGBA8:
//		{
//			if (webpProperties.lossless)
//				bytesWritten = WebPEncodeLosslessRGBA(pixels, properties.width, properties.height, properties.width * bpp(properties.format), &output);
//			else
//				bytesWritten = WebPEncodeRGBA(pixels, properties.width, properties.height, properties.width * bpp(properties.format), webpProperties.quality, &output);
//			break;
//		}
//	}
//
//	if (bytesWritten > 0)
//		fileHandle->write(output, bytesWritten);
//
//	fileHandle->close();
//	WebPFree(output);
//
//	return (bytesWritten > 0);
//}
//
//}