47 dataBuffer.
resize(pos + blockSize);
48 int num = stream.
read(dataBuffer.
getPtr(pos), blockSize);
51 dataBuffer.
resize(pos + num);
61 LodePNG::Decoder decoder;
63 Vec2i size(decoder.getWidth(), decoder.getHeight());
66 if (decoder.hasError())
67 setError(
"importLodePngImage(): LodePNG error %d!", decoder.getError());
69 setError(
"importLodePngImage(): Invalid image size!");
75 int numBytes =
size.x *
size.y * ((hasAlpha) ? 4 : 3);
76 std::vector<U8> pixelBuffer;
77 pixelBuffer.reserve(numBytes);
78 decoder.getInfoRaw().color.colorType = (hasAlpha) ? 6 : 2;
79 decoder.decode(pixelBuffer, dataBuffer.
getPtr(), dataBuffer.
getSize());
81 if (decoder.hasError())
82 setError(
"importLodePngImage(): LodePNG error %d!", decoder.getError());
83 if ((
int)pixelBuffer.size() != numBytes)
84 setError(
"importLodePngImage(): Incorrect amount of pixel data!");
109 converted =
new Image(size, format);
115 LodePNG::Encoder encoder;
116 int colorType = (hasAlpha) ? 6 : 2;
117 encoder.getSettings().autoLeaveOutAlphaChannel =
false;
118 encoder.getInfoRaw().color.colorType = colorType;
119 encoder.getInfoPng().color.colorType = colorType;
121 std::vector<U8> dataBuffer;
122 encoder.encode(dataBuffer, (
U8*)((converted) ? converted : image)->getPtr(), size.x, size.y);
124 if (encoder.hasError())
125 setError(
"exportLodePngImage(): LodePNG error %d!", encoder.getError());
129 if (!
hasError() && !dataBuffer.empty())
130 stream.
write(&dataBuffer[0], (
int)dataBuffer.size());
void set(const void *ptr)
void setError(const char *fmt,...)
virtual void write(const void *ptr, int size)=0
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
Image * importLodePngImage(InputStream &stream)
Buffer & getBuffer(void) const
const Vec2i & getSize(void) const
const ImageFormat & getFormat(void) const
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
void exportLodePngImage(OutputStream &stream, const Image *image)
unsigned LodePNG_InfoColor_canHaveAlpha(const LodePNG_InfoColor *info)
const T * getPtr(S idx=0) const
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void * image
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size