Lines Matching full:to
10 Permission is granted to anyone to use this software for any purpose,
11 including commercial applications, and to alter it and redistribute it
12 freely, subject to the following restrictions:
39 The following #defines are used to create code sections. They can be disabled
40 to disable code sections, which can give faster compile time and smaller binary.
41 The "NO_COMPILE" defines are designed to be used to pass as defines to the
42 compiler command to disable them without modifying this header, e.g.
48 …/*pass -DLODEPNG_NO_COMPILE_ZLIB to the compiler to disable this, or comment out LODEPNG_COMPILE_Z…
54 …/*pass -DLODEPNG_NO_COMPILE_PNG to the compiler to disable this, or comment out LODEPNG_COMPILE_PN…
60 …/*pass -DLODEPNG_NO_COMPILE_DECODER to the compiler to disable this, or comment out LODEPNG_COMPIL…
66 …/*pass -DLODEPNG_NO_COMPILE_ENCODER to the compiler to disable this, or comment out LODEPNG_COMPIL…
72 …/*pass -DLODEPNG_NO_COMPILE_DISK to the compiler to disable this, or comment out LODEPNG_COMPILE_D…
78 /*pass -DLODEPNG_NO_COMPILE_ANCILLARY_CHUNKS to the compiler to disable this,
83 /*ability to convert error numerical codes to English text string*/
85 /*pass -DLODEPNG_NO_COMPILE_ERROR_TEXT to the compiler to disable this,
94 /*pass -DLODEPNG_NO_COMPILE_ALLOCATORS to the compiler to disable the built-in ones,
105 /*pass -DLODEPNG_NO_COMPILE_CRC to the compiler to disable the built-in one,
113 … /*pass -DLODEPNG_NO_COMPILE_CPP to the compiler to disable C++ (not needed if a C-only compiler),
132 /*LCT_MAX_OCTET_VALUE lets the compiler allow this enum to represent any invalid
133 byte value from 0 to 255 that could be present in an invalid PNG file header. Do
136 particular disallowed color type byte values, or cast to integer to print it.*/
142 Converts PNG data in memory to raw pixel data.
143 out: Output parameter. Pointer to buffer that will contain the raw pixel data.
148 w: Output parameter. Pointer to width of pixel data.
149 h: Output parameter. Pointer to height of pixel data.
160 /*Same as lodepng_decode_memory, but always decodes to 32-bit RGBA raw image*/
164 /*Same as lodepng_decode_memory, but always decodes to 24-bit RGB raw image*/
174 to handle such files and decode in-memory.*/
179 /*Same as lodepng_decode_file, but always decodes to 32-bit RGBA raw image.
182 to handle such files and decode in-memory.*/
186 /*Same as lodepng_decode_file, but always decodes to 24-bit RGB raw image.
189 to handle such files and decode in-memory.*/
202 out: Output parameter. Pointer to buffer that will contain the PNG image data.
204 outsize: Output parameter. Pointer to the size in bytes of the out buffer.
205 image: The raw pixel data to encode. The size of this buffer should be
233 to handle such files and encode in-memory.*/
241 to handle such files and encode in-memory.*/
248 to handle such files and encode in-memory.*/
259 /*Same as lodepng_decode_memory, but decodes to an std::vector. The colortype
260 is the format to output the pixels to. Default is RGBA 8-bit per channel.*/
269 Converts PNG file from disk to raw pixel data in memory.
273 to handle such files and decode in-memory.
282 /*Same as lodepng_encode_memory, but encodes to an std::vector. colortype
298 to handle such files and decode in-memory.
325 /*Maximum decompressed size, beyond this the decoder may (and is encouraged to) stop decoding,
326 return an error, output a data size > max_output_size and all the data up to that point. This is
329 Set to 0 to impose no limit (the default).*/
360 unsigned use_lz77; /*whether or not to use LZ77. Should be 1 for proper compression.*/
363 …unsigned nicematch; /*stop searching if >= this length found. Set to 258 for best compression. Def…
386 Color mode of an image. Contains all information required to decode the pixel
387 bits to RGBA colors. This information is the same as used in the PNG file
400 then lodepng_palette_add per color to correctly initialize it (to ensure size
403 The alpha channels must be set as well, set them to 255 for opaque images.
407 but when decoding to the original PNG color mode it is needed to reconstruct
418 …This color uses the same bit depth as the bitdepth value in this struct, which can be 1-bit to 16-…
419 For grayscale PNGs, r, g and b will all 3 be set to the same.
422 pixels with this key to transparent already in the raw RGBA output.
432 /*init, cleanup and copy functions to use with this struct*/
441 /*add 1 color to the palette*/
457 Loops through the palette to check this.*/
478 unsigned second; /*0-60 (to allow for leap seconds)*/
495 with values truncated to the bit depth in the unsigned integer.
499 equal to background_r, the encoder ignores them in this case.
507 use it to interpret these values (and convert copies of them to its chosen color model).
509 When encoding, avoid setting this to an expensive color, such as a non-gray value
510 when the image is gray, or the compression will be worse since it will be forced to
513 The decoder does not use this background color to edit the color of pixels. This is a
530 characters to appear in the main text which is why we can use null termination everywhere here.
533 additional null terminator). It's discouraged to use a single line length
547 Similar to the non-international text chunks, but with additional strings
556 char ** itext_transkeys; /*keyword translated to the international language - UTF-8 string*/
560 unsigned time_defined; /*set to 1 to make the encoder generate a tIME chunk*/
573 …profile values. It merely passes on the information. If you wish to use color profiles and convert…
606 …separate library to handle the ICC data (not included in LodePNG) format is needed to use it for c…
609 …For encoding, if iCCP is present, gAMA and cHRM are recommended to be added as well with values th…
610 …profile as closely as possible, if you wish to do this you should provide the correct values for g…
613 …For encoding, the ICC profile is required by the PNG specification to be an "RGB" profile for non-…
620 …To avoid this do not set an ICC profile in the image unless there is a good reason for it, and whe…
621 make sure you compute it carefully to avoid the above problems.
637 …per channel data, the significant bits value can be used to indicate the original encoded data has…
641 of the data to store the original bits, and use a good sample depth scaling method such as
642 "left bit replication" to fill in the least significant bits, rather than fill zeroes.
644 Decoders using this value, if able to work with data that's e.g. 10-bit or 12-bit, should right
645 shift the data to go back to the original bit depth, but decoders are also allowed to ignore
647 to the encoder contract, the values encoded in PNG are in valid range for the PNG bit depth.
652 greater than zero and smaller than or equal to the PNG bit depth.
655 decoding with a color mode conversion, such as always decoding to RGBA, this metadata still
661 auto_convert to choose a more optimal color mode for the data, because the PNG format has
663 …For example, setting these fields to 10-bit will force the encoder to keep using a 16-bit per chan…
686 …this if you wish to store an ancillary chunk that is not supported by LodePNG (such as sPLT or hIS…
690 later, such as lodepng_chunk_next and lodepng_chunk_append, to read/write this struct.
697 /*init, cleanup and copy functions to use with this struct*/
705 void lodepng_clear_text(LodePNGInfo * info); /*use this to clear the texts again after you filled t…
709 void lodepng_clear_itext(LodePNGInfo * info); /*use this to clear the itexts again after you filled…
713 void lodepng_clear_icc(LodePNGInfo * info); /*use this to clear the texts again after you filled th…
717 Converts raw buffer from one color type to another color type, based on
718 LodePNGColorMode structs to describe the input and output color type.
719 See the reference manual at the end of this header file to see which color conversions are supporte…
737 LodePNGDecompressSettings zlibsettings; /*in here is the setting to ignore Adler32 checksums*/
748 unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/
757 …unless reading text chunks is disabled or this limit is set higher or disabled. Set to 0 to allow …
761 …or compressed ICC chunks. If the ICC profile is larger than this, an error will be returned. Set to
762 …0 to allow any size. By default this is a value that prevents ICC profiles that would be much larg…
763 legitimate profile could be to hog memory. */
796 which helps decide which color model to use for encoding.
805 …unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16 or allow_palette is dis…
807 …palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order, only valid whe…
831 8 bit depth, set all filters to zero. Otherwise use the filter_strategy. Note that to
835 /*Which filter strategy to use when not using zeroes due to filter_palette_zero.
836 Set filter_palette_zero to 0 to ensure always using your chosen strategy. Default: LFS_MINSUM*/
838 /*used if filter_strategy is LFS_PREDEFINED. In that case, this must point to a buffer with
840 have to cleanup this buffer, LodePNG will never free it. Don't forget that filter_palette_zero
841 must be set to 0 to ensure this is also used on palette or low bitdepth images.*/
846 to a grayscale type (1 or 4), this is not done and is ignored. If enabling this,
848 NOTE: enabling this may worsen compression if auto_convert is used to choose
872 …LodePNGColorMode info_raw; /*specifies the format in which you would like to get the raw pixel buf…
877 /*init, cleanup and copy functions to use with this struct*/
885 Same as lodepng_decode_memory, but uses a LodePNGState to allow custom settings and
906 to find the desired chunk type, and if non null use lodepng_inspect_chunk (with
910 Requirements: &in[pos] must point to start of a chunk, must use regular
925 The lodepng_chunk functions are normally not needed, except to traverse the
926 unknown chunks stored in the LodePNGInfo struct, or add new ones to it.
929 The chunk pointer always points to the beginning of the chunk itself, that is
945 -Fourth byte: uppercase = unsafe to copy, lowercase = safe to copy
950 There must be at least 4 bytes to read from. If the result value is too large,
967 /*0: the chunk is unsafe to copy, 1: the chunk is safe to copy (see PNG standard)*/
970 /*get pointer to the data of the chunk, where the input points to the header of the chunk*/
981 Iterate to next chunks, allows iterating through all chunks of the PNG file.
984 point to the first byte of the PNG file (which is not a chunk but the magic header, the
986 Will output pointer to the start of the next chunk, or at or beyond end of the file if there
1000 Appends chunk to the data in out. The given chunk should already have its chunk header.
1001 The out variable and outsize are updated to reflect the new reallocated buffer.
1007 Appends new chunk to out. The chunk to append is given by giving its length, type
1009 The out variable and outsize are updated to reflect the new reallocated buffer.
1023 This zlib part can be used independently to zlib compress and decompress a
1024 buffer. It cannot be used to create gzip files however, and it only supports the
1036 data must be according to the zlib specification.
1076 out: output parameter, contains pointer to loaded buffer.
1078 filename: the path to the file to load
1082 to handle such files and decode in-memory.
1087 Save a file from buffer to disk. Warning, if it exists, this function overwrites
1089 buffer: the buffer to write
1090 buffersize: size of the buffer to write
1091 filename: the path to the file to save to
1095 to handle such files and encode in-memory
1140 to handle such files and decode in-memory
1145 Save the binary data in an std::vector to a file on disk. The file is overwritten
1149 to handle such files and encode in-memory
1181 [.] test if there are no memory leaks or security exploits - done a lot but needs to be checked oft…
1182 [.] check compatibility with various compilers - done but needs to be redone for every newer versi…
1183 [X] converting color to 16-bit per channel types
1196 [ ] allow user to provide custom color conversion functions, e.g. for premultiplied alpha, padding …
1197 [ ] allow user to give data (void*) to custom allocator
1242 PNG is a file format to store raster images losslessly with good compression,
1245 LodePNG is a PNG codec according to the Portable Network Graphics (PNG)
1267 If you want to start using LodePNG right away without reading this doc, get the
1268 examples from the LodePNG website to see how to use it in code, or check the
1271 LodePNG is simple but only supports the basic requirements. To achieve
1273 on any external library. There are functions to decode and encode a PNG with
1275 LodePNGState struct allowing to specify or get more information. By default
1277 the PNG file uses. To read and write files, there are simple functions to
1278 convert the files to/from buffers in memory.
1282 over network (it requires all the image data to be available before decoding can
1290 *) decoding of PNGs with any color type, bit depth and interlace mode, to a 24- or 32-bit color raw…
1292 *) encoding of PNGs, from any raw image to 24- or 32-bit color, or the same color type as the raw i…
1300 …plus alternatively ability to pass on chroma/gamma/ICC profile information to other color manageme…
1325 *) some features needed to make a conformant PNG-Editor might be still missing.
1333 The C version uses buffers allocated with alloc that you need to free()
1334 yourself. You need to use init and cleanup functions for each struct whenever
1335 using a struct from the C version to avoid exploits and memory leaks.
1342 ignore it, and the C code is made to compile both with strict ISO C90 and C++.
1344 To use the C++ version, you need to rename the source file to lodepng.cpp
1347 To use the C version, you need to rename the source file to lodepng.c (instead
1357 When using LodePNG, care has to be taken with the C version of LodePNG, as well
1362 -if a struct has a corresponding cleanup function, call it before the struct disappears to avoid me…
1370 Decoding converts a PNG compressed image to a raw pixel buffer.
1381 …GColorMode info_raw: here you can say what color mode of the raw image (the output) you want to get
1382 *) LodePNGDecoderSettings decoder: you can specify a few extra settings for the decoder to use
1399 the resulting raw image to be. If this is different from the colortype of the
1401 always works, except if you want it to convert a color PNG to grayscale or to
1409 The settings can be used to ignore the errors created by invalid CRC and Adler32
1410 chunks, and to disable the decoding of tEXt chunks.
1414 and you'll have to puzzle the colors of the pixels together yourself using the
1421 Encoding converts a raw pixel buffer to a PNG compressed image.
1435 *) LodePNGInfo info_png: here you specify how you want the PNG (the output) to be.
1437 *) LodePNGEncoderSettings encoder: you can specify a few settings for the encoder to use
1443 you fill in the values you want the PNG to have before encoding. By default it's
1444 not needed to specify a color type for the PNG since it's automatically chosen,
1445 but it's possible to choose it yourself given the right settings.
1453 When encoding to a PNG with colortype 3, the encoder will generate a PLTE chunk.
1460 You specify the color type of the raw image that you give to the input here,
1461 including a possible transparent color key and palette you happen to be using in
1464 By default, 32-bit color is assumed, meaning your input has to be in RGBA
1477 *) use_lz77: whether or not to use LZ77 for compressed block types. Should be
1480 2048 by default, but can be set to 32768 for better, but slow, compression.
1482 chunk if force_palette is true. This can used as suggested palette to convert
1483 to by viewers that don't support more than 256 colors (if those still exist)
1484 *) add_id: add text chunk "Encoder: LodePNG <version>" to the image.
1494 An important thing to note about LodePNG, is that the color type of the PNG, and
1500 of colors in the image. It can be configured to let you control it instead as
1503 To be able to do this, LodePNG does conversions from one color mode to another.
1504 It can convert from almost any color type to any other color type, except the
1505 following conversions: RGB to grayscale is not supported, and converting to a
1508 reduction algorithm that is beyond the scope of a PNG encoder (yes, RGB to gray
1509 is easy, but there are multiple ways if you want to give some channels more
1515 the input image to be 32-bit RGBA or 24-bit RGB. So, unless you want to control
1521 A PNG image can have many color types, ranging from 1-bit color to 64-bit color,
1525 decoding to have another color type, a conversion is done by LodePNG.
1542 color types and bit depths in info_png and info_raw to change the default
1545 If, when decoding, you want the raw image to be something else than the default,
1546 you need to set the color type and bit depth you want in the LodePNGColorMode,
1550 image, you need to specify its color type and bit depth in the LodePNGColorMode
1554 If, when encoding, you don't want LodePNG to choose the output PNG color type
1555 but control it yourself, you need to set auto_convert in the encoder settings
1556 to false, and specify the color type you want in the LodePNGInfo of the
1564 To avoid some confusion:
1565 -the decoder converts from PNG to raw image
1566 -the encoder converts from raw image to PNG
1571 -when decoding, the color type in LodePNGInfo is set by the decoder to that of the original
1577 colortype and saving PNGs to any colortype, sometimes it just requires preparing
1586 -color to grayscale when non-gray pixels are present: no error is thrown, but
1589 no error is given is to allow converting from three-channel grayscale images to
1591 -anything to palette when the palette does not have an exact match for a from-color
1595 -anything to 8-bit RGB, 8-bit RGBA, 16-bit RGB, 16-bit RGBA
1596 -any gray or gray+alpha, to gray or gray+alpha
1597 -anything to a palette, as long as the palette has the requested colors in it
1599 -higher to smaller bitdepth, and vice versa
1601 If you want no color conversion to be done (e.g. for speed or control):
1603 raw color mode and LodePNGInfo the same color mode, and setting auto_convert to
1606 as the PNG has, by setting the color_convert setting to false. Settings in
1615 The raw input image you give to the encoder, and the raw output image you get from the decoder
1629 Conversions to other formats than PNG uses internally are not supported by
1632 converting to/from all that is outside the scope of LodePNG.
1634 This may mean that, depending on your use case, you may want to convert the big
1635 endian output of LodePNG to little endian with a for loop. This is certainly not
1637 anyway, but it means you cannot simply cast the unsigned char* buffer to an
1651 Check the implementation of lodepng_error_text to see the meaning of each code.
1653 It is not recommended to use the numerical values to programmatically make
1654 different decisions based on error types as the numbers are not guaranteed to
1662 If you want to add extra chunks to a PNG you encode, or use LodePNG for a PNG
1664 program is able to read other types of chunks than the ones handled by LodePNG,
1682 NOTE: none of these functions check for memory buffer boundaries. To avoid
1702 Check if the chunk is safe to copy. If it's not, then, when modifying data in a critical
1703 chunk, unsafe to copy chunks of the old image may NOT be saved in the new one if your
1709 Get a pointer to the start of the data of the chunk.
1719 Iterate to the next chunk. This works if you have a buffer with consecutive chunks. Note that these
1721 data available in the buffer to be able to go to the next chunk.
1727 These functions are used to create new chunks that are appended to the data in *out that has
1728 length *outsize. The append function appends an existing chunk to the new data. The create
1736 buffers (each with size) to contain 3 types of unknown chunks:
1739 It's necessary to make the distinction between these 3 cases because the PNG
1740 standard forces to keep the ordering of unknown chunks compared to the critical
1750 When using the decoder to decode a PNG, you can make it store all unknown chunks
1751 if you set the option settings.remember_unknown_chunks to 1. By default, this
1755 If you need it to add a particular chunk that isn't known by LodePNG, you can
1756 use lodepng_chunk_append or lodepng_chunk_create to the chunk data in
1759 Chunks that are known by LodePNG should not be added in that way. E.g. to make
1760 LodePNG add a bKGD chunk, set background_defined to true and add the correct
1767 No libraries other than the current standard C library are needed to compile
1769 Add the files lodepng.c(pp) and lodepng.h to your project, include
1802 where it wants to use a non-standard function fopen_s instead of the standard C
1805 Visual Studio may want "stdafx.h" files to be included in each source file and
1807 This is not standard C++ and will not be added to the stock LodePNG. You can
1809 Precompiled Headers, and set it to Not Using Precompiled Headers there.
1812 VS6, are not guaranteed to work.
1816 LodePNG has been reported to work both with gcc and LLVM for Macintosh, both for
1821 If you encounter problems on any compilers, feel free to let me know and I may
1822 try to fix it if the compiler is modern and standards compliant.
1832 external method to handle such files and encode or decode in-memory
1878 A quick reference of some settings to set on the LodePNGState
1887 state.decoder.color_convert: convert internal PNG color to chosen one
1888 state.decoder.read_text_chunks: whether to read in text metadata chunks
1889 state.decoder.remember_unknown_chunks: whether to read in unknown chunks
1897 state.encoder.zlibsettings.btype: disable compression by setting it to 0
1900 state.encoder.zlibsettings.minmatch: tweak min LZ77 length to match
1901 state.encoder.zlibsettings.nicematch: tweak LZ77 match where to stop searching
1906 state.encoder.filter_strategy: PNG filter strategy to encode with
1907 state.encoder.force_palette: add palette even if not encoding to one
1939 *) 12 jan 2020: (!) added 'end' argument to lodepng_chunk_next to allow correct
1941 *) 14 aug 2019: around 25% faster decoding thanks to huffman lookup tables.
1943 if gray ICC profile) and non-ICC LodePNGColorProfile renamed to
1946 *) 10 sep 2018: added way to inspect metadata chunks without full decoding.
1955 *) 18 apr 2016: Changed qsort to custom stable sort (for platforms w/o qsort).
1959 *) 24 okt 2015: Bugfix with decoding to palette output.
1961 *) 24 aug 2014: Moved to github
1968 *) 25 mar 2013: Added an optional feature to ignore some PNG errors (fix_png).
1969 *) 11 mar 2013: (!) Bugfix with custom free. Changed from "my" to "lodepng_"
1970 prefix for the custom allocators and made it possible with a new #define to
1971 use custom ones in your project without needing to change lodepng's code.
1980 *) 23 jun 2012: Added more filter strategies. Made it easier to use custom alloc
1994 better ones (it's quite significant). A setting to do an experimental, slow,
1998 *) 17 apr 2011: code cleanup. Bugfixes. Convert low to 16-bit per sample colors.
2001 to optimize long sequences of zeros.
2004 *) 7 nov 2010: added LodePNG_error_text function to get error code description.
2009 *) 05 jul 2010: fixed bug thanks to warnings in the new gcc version.
2014 *) 26 apr 2008: added a few more checks here and there to ensure more safety.
2017 *) 23 jan 2008: small cleanups, and #defines to divide code in sections
2019 *) 18 jan 2008: support for tIME and pHYs chunks added to encoder and decoder.
2020 *) 17 jan 2008: ability to encode and decode compressed zTXt chunks added
2022 *) 13 jan 2008: Added ability to encode Adam7-interlaced images. Improved
2024 *) 07 jan 2008: (!) changed LodePNG to use ISO C90 instead of C++. A
2025 C++ wrapper around this provides an interface almost identical to before.
2028 *) 29 dec 2007: (!) changed most integer types to unsigned int + other tweaks
2039 moved some examples from here to lodepng_examples.cpp
2041 *) 24 apr 2007: changed the license from BSD to the zlib license
2042 *) 11 mar 2007: very simple addition: ability to encode bKGD chunks.
2051 greyscale type to 8-bit greyscale with or without alpha.
2053 to convert to and is more uniform. See the manual for how it works now.
2060 *) 28 dec 2006: Added "Settings" to the encoder.
2068 *) 08 sep 2006: (!) Changed to interface with a Decoder class
2070 way. Renamed decodePNG to decodePNGGeneric.
2077 *) 22 jun 2006: (!) Changed way to obtain error value. Added
2079 *) 21 jun 2006: (!) Changed type of info vector to unsigned.
2084 *) 07 jun 2006: (!) Renamed functions to decodePNG and placed them
2086 documentation in the header. Renamed files to lodepng.cpp and lodepng.h
2088 *) 07 sep 2005: (!) Changed to std::vector interface
2095 Feel free to contact me with suggestions, problems, comments, ... concerning
2097 decoder, feel free to send it and I'll use it to find and fix the problem.