#ifndef __JBXL_CPP_JPEG_TOOl_H_ #define __JBXL_CPP_JPEG_TOOl_H_ /** @brief JPEGグラフィックデータ定義用ヘッダ @file JpegTool.h @version 0.9 @date 2009 3/8 @author Fumi.Iseki (C) @attention this software is based in part on the work of the Independent JPEG Group. http://www.ijg.org/ */ #include "Gdata.h" #include "xtools.h" #ifndef HAVE_JPEGLIB_H #ifndef DISABLE_JPEGLIB #define DISABLE_JPEGLIB #endif #endif #ifdef DISABLE_JPEGLIB #undef ENABLE_JPEGLIB #endif #ifdef ENABLE_JPEGLIB #undef HAVE_STDLIB_H #include #ifdef WIN32 #pragma comment(lib, "libjpeg.lib") #endif // namespace jbxl { //////////////////////////////////////////////////////////////////////////////////////////// class JPEGImage { public: int xs; int ys; int col; int state; JSAMPLE* gp; JSAMPARRAY image; public: JPEGImage(void) { init();} virtual ~JPEGImage(void) {} void init(void); ///< グラフィックデータは解放しない bool isNull(void); ///< グラフィックデータを持っていないか? void clear(void); ///< 全空間を画素値 0 にする void fill(JSAMPLE v=(JSAMPLE)0); ///< 全空間を画素値 v にする void free(void); ///< グラフィックデータを開放する JSAMPLE& point(int x, int y, int c) { return image[y][x*col + c];} void getm(int x, int y, int c); void set (int x, int y, int c); }; ////////////////////////////////////////////////////////////////////////////////////////////////// JPEGImage readJPEGFile (const char* fname); JPEGImage readJPEGData (FILE* fp); int writeJPEGFile(const char* fname, JPEGImage jp, int qulty); int writeJPEGData(FILE* fp, JPEGImage jp, int qulty); int isJPEGHeader(Buffer buf); CmnHead JPEGImage2CmnHead(JPEGImage jp); JPEGImage CmnHead2JPEGImage(CmnHead hd); // template MSGraph JPEGImage2MSGraph(JPEGImage jp) // template JPEGImage MSGraph2JPEGImage(MSGraph vp) /** template MSGraph JPEGImage2MSGraph(JPEGImage jp) Jpegイメージデータを MSGraph型イメージデータに変換する @param jp Jpegイメージデータ @return MSGraphイメージデータ @retval JBXL_GRAPH_NODATA_ERROR @b state データ無し @retval JBXL_GRAPH_MEMORY_ERROR @b state メモリ確保エラー */ template MSGraph JPEGImage2MSGraph(JPEGImage jp) { MSGraph vp; if (jp.isNull()) { vp.state = JBXL_GRAPH_NODATA_ERROR; return vp; } vp.set(jp.xs, jp.ys, jp.col); if (vp.isNull()) return vp; //if (jp.col==3) vp.color = GRAPH_COLOR_PRGB; if (jp.col==3) vp.color = GRAPH_COLOR_RGB; for (int k=0; k JPEGImage MSGraph2JPEGImage(MSGraph vp) MSGraph型イメージデータを Jpegイメージデータに変換する @param vp MSGraph型イメージデータ @return Jpegイメージデータ @retval JBXL_GRAPH_NODATA_ERROR @b state データ無し @retval JBXL_GRAPH_MEMORY_ERROR @b state メモリ確保エラー */ template JPEGImage MSGraph2JPEGImage(MSGraph vp) { JPEGImage jp; if (vp.isNull()) { jp.state = JBXL_GRAPH_NODATA_ERROR; return jp; } jp.set(vp.xs, vp.ys, vp.zs); if (jp.isNull()) return jp; for (int k=0; k