2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
33 //#define NEED_FAR_POINTERS
34 #define XMD_H //workaround some compiling issues
43 //TODO find a replacement on WIN32
49 //a reader to be implemented by the caller
52 //init reading the file
53 //return <=0 if error or size of image
54 virtual ULONG initRead(const char *filename)=0;
55 //read the next chunk of jpeg data
56 //offset - from start of file
57 //len I buf len (max bytes to read)
58 //return read len, 0 on EOF, -1 on error, *buf set to buffer
59 //will be released with free(!!!) after decoding
60 virtual ULONG readChunk(ULONG offset,ULONG len,char **buf)=0;
61 virtual ~JpegReader(){};
64 class WindowsResourceJpegReader: public JpegReader {
66 virtual ULONG initRead(const char *filename);
67 virtual ULONG readChunk(ULONG offset,ULONG len,char **buf);
68 virtual ~WindowsResourceJpegReader();
76 class WJpeg : public Boxx
81 void setDimensions(int width, int height) {area.w=width;area.h=height;};
86 int init(char* fileName, bool useImage=true, JpegReader *rdr=NULL);
87 //rotate (with next draw!) by 90/180/270
88 void setRotate(int amount);
89 static const int ROT_0=0;
90 static const int ROT_90=1;
91 static const int ROT_180=2;
92 static const int ROT_270=3;
96 * get an integer info from the current picture
98 ULONG getJpegInfo(ULONG tag);
100 static const ULONG JPEG_WIDTH=1; //picture width
101 static const ULONG JPEG_HEIGHT=2; //picture height
102 static const ULONG JPEG_SIZE=3; //picture (compressed) size
103 static const ULONG JPEG_ROTATE=4; //rotate setting
104 static const ULONG JPEG_SCALE=5; //scale setting (1/n)
106 * get a string info from the picture
107 * the user must provide a buffer of
110 int getJpegInfo(ULONG tag, char * buffer);
111 static const int INFO_BUFFER=200;
113 static const ULONG JPEG_FILENAME=100; //abbreviated filename
117 //our drawPixel with considers rotation
118 void drawPixel(int x, int y,int w,int h,int xpos, int ypos, const Colour& c);
122 WindowsResourceJpegReader winread;
124 bool useImageDimensions;