#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" #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 img; 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 img[y][x*col + c];} void getm(int x, int y, int c); void set (int x, int y, int c); }; JPEGImage readJPEGFile (char* fname); JPEGImage readJPEGData (FILE* fp); int writeJPEGFile(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 ERROR_GRAPH_NODATA @b state データ無し @retval ERROR_GRAPH_MEMORY @b state メモリ確保エラー */ template MSGraph JPEGImage2MSGraph(JPEGImage jp) { MSGraph vp; int i, j, k, yp, zp; vp.init(); // vp.color = GRAPH_COLOR_MONO; if (jp.col==3) vp.color = GRAPH_COLOR_PRGB; if (jp.isNull()) { vp.state = ERROR_GRAPH_NODATA; return vp; } vp.set(jp.xs, jp.ys, jp.col); if (vp.isNull()) return vp; for (k=0; k JPEGImage MSGraph2JPEGImage(MSGraph vp) Jpegイメージデータを MSGraph型イメージデータに変換する @param vp MSGraph型イメージデータ @return Jpegイメージデータ @retval ERROR_GRAPH_NODATA @b state データ無し @retval ERROR_GRAPH_MEMORY @b state メモリ確保エラー */ template JPEGImage MSGraph2JPEGImage(MSGraph vp) { JPEGImage jp; int i, j, k, yp, zp; jp.init(); if (vp.isNull()) { jp.state = ERROR_GRAPH_NODATA; return jp; } jp.set(vp.xs, vp.ys, vp.zs); if (jp.isNull()) return jp; for (k=0; k