libpng で(ファイルストリームでなく)配列変数から直接 PNGデータを読み書きする方法がようやく分かったので、 その顛末。 libpng の使い方のページを探しても、ファイルポインタを渡すのばかりで メモリオブジェクトを直接渡すサンプルプログラムが殆ど見つかりません。 その上、見つけたモノもオーバーフロウの対策が入ってない(ように見える)ので、 libpng.txt を見直すことにしました。 伝説のお茶の間 libpng1.2.8 libpng.txt 訳 libpng にある入出力はpng_read() や png_write() を通して処理されます。 現行では fread() や fwrite() を呼ぶだけです。FILE * は png_struct 内部に記憶され、png_init_io() を経由して初期化されます。 I/O 命令を変更したいなら、png_init_io(
メモリ上に確保したPNGデータをlibpngに読み込んでもらってlibpngから画像データを取得してみる感じです。 /* read_png_from_mem.c * メモリ上にある、PNGデータをlibpngを介して読み込むサンプル。 * 参考: * http://d.hatena.ne.jp/yoya/20080714 * http://diary.awm.jp/~yoya/data/2008/07/14/png_test.c * http://gmoon.jp/png/ */ #include <stdio.h> #include <stdlib.h> #include <png.h> typedef struct my_png_buffer_ { unsigned char *data; /* PNGのデータが入ったメモリへのポインタ */ unsigned long data_le
#include <png.h> #include <pnginfo.h> // データ読込時のコールバック関数 int offset = 0; void ReadEndProcess( png_structp _pPng, png_bytep _buf, png_size_t _size ) { uint8* p = (uint8*)png_get_io_ptr( _pPng ); memcpy( _buf, p+offset, _size ); offset += _size; } bool IsPNG( const uint8* _pData ) { if( png_sig_cmp( _pData, 0, 8 ) != 0 ) { return false; } return true; } // テクスチャの読み込み。 bool Load( const uint8* _pData,
LibPng: PNG image compression library Version 1.2.37 Description The libpng package contains a library of functions for creating and manipulating PNG (Portable Network Graphics) image format files. PNG is a bit-mapped graphics format similar to the GIF format. PNG was created to replace the GIF format, since GIF uses a patented data compression algorithm. Libpng should be installed if you need to
libpng is the official PNG reference library. It supports almost all PNG features, is extensible, and has been extensively tested for over 28 years. The home site for development versions (i.e., may be buggy or subject to change or include experimental features) is https://libpng.sourceforge.io/, and the place to go for questions about the library is the png-mng-implement mailing list. libpng is a
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く