The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C++ Code
Posted by: Shane | November 29, 2010 @ 8:28pm
C++ Code
[
Download
]
png_voidp __cdecl PngAlloc( png_structp, png_alloc_size_t size ) { return g_engineHeap.Alloc( size, __FILE__, __LINE__ ); } void __cdecl PngFree( png_structp, png_voidp ptr ) { wfHeap::Free( ptr ); } void __cdecl PngRead( png_structp pngPtr, png_bytep data, png_size_t length ) { u8* src = reinterpret_cast< u8* >( pngPtr->io_ptr ); memcpy( data, src, length ); pngPtr->io_ptr = src + length; } u32* data = new( g_engineHeap )u32[ m_header.m_width * m_header.m_height ]; png_structp png = png_create_read_struct_2( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL, NULL, PngAlloc, PngFree ); png_infop pngInfo = png_create_info_struct( png ); png_set_read_fn( png, rawData, PngRead ); u32* dst = data; png_bytepp rows = new( g_engineHeap )png_bytep[ m_header.m_height ]; for( s32 rowIdx = 0; rowIdx != m_header.m_height; ++rowIdx ) { rows[ rowIdx ] = reinterpret_cast< png_bytep >( dst ); dst += m_header.m_width; } png_set_rows( png, pngInfo, rows ); #ifdef WF_PC32 png_read_png( png, pngInfo, PNG_TRANSFORM_BGR, NULL ); #else png_read_png( png, pngInfo, PNG_TRANSFORM_SWAP_ALPHA, NULL ); #endif delete[] rows; png_destroy_read_struct( &png, &pngInfo, NULL ); return reinterpret_cast< u8* >( data );
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.63 / 8
38 Votes
http://codebin.yi.org/987
page generated in 0.01 seconds