14 #include <FXPNGImage.h> 17 #include <FXJPGImage.h> 20 #include <FXTIFImage.h> 22 #include <FXICOImage.h> 23 #include <FXTGAImage.h> 24 #include <FXRGBImage.h> 47 m_Dim1(0), m_Dim2(0), m_Dim3(0), m_NChannels(0),
48 m_CurrImage(0),m_ppmm(
DEFAULT_PPMM),m_RefreshImage(false),
49 m_HalveBeyondSize(0xffffffff)
70 if(
data[0].getSizeY()>3 &&
data[0].getSizeX()>3) {
74 for(vector< ByteImage >::iterator ii=
data.begin();
78 *ii = ii->scaleBy(0.5);
80 cout <<
"reducing image" << endl;
84 double avgcol = copimg.
sum()/
86 ii->zeroPad(brd,
byte(avgcol));
88 dword nx = (ii->getSizeX()/2+1)*2;
89 dword ny = (ii->getSizeY()/2+1)*2;
160 FXString ext=FXPath::extension(file);
162 FXApp *app = FXApp::instance();
164 if(comparecase(ext,
"bmp")==0){
165 img=
new FXBMPImage(app,
NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
167 else if(comparecase(ext,
"gif")==0){
168 img=
new FXGIFImage(app,
NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
170 else if(comparecase(ext,
"tga")==0){
171 img=
new FXTGAImage(app,
NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
174 else if(comparecase(ext,
"png")==0){
175 img=
new FXPNGImage(app,
NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
179 else if(comparecase(ext,
"jpg")==0){
180 img=
new FXJPGImage(app,
NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
184 else if(comparecase(ext,
"tif")==0 || comparecase(ext,
"tiff")==0){
185 img=
new FXTIFImage(app,
NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
188 bool load_ok =
false;
192 if(stream.open(file,FXStreamLoad)){
194 load_ok = img->loadPixels(stream);
214 for(vector< ByteImage >::iterator ii=
data.begin();
218 for(
int i=ii->getSize(); i>0; i--, data++)
220 int val = int(
int(*data) +
fgauss01()*sigma);
222 else if(val>255) *data = 255;
223 else *data =
byte(val);
233 glRasterPos3f(x,y,0.0f);
242 const int comp = img.size()>3 ? 3 : img.size();
243 int size = img[0].size();
248 for(
int i=0; i!=size; i++, cv++, bi++)
252 for(
int a=0; a<comp; a++) bi[a] = img[a].begin();
254 for(
int i=0; i<size; i++) {
255 *(cv++) = *bi[0]; bi[0]++;
256 *(cv++) = *bi[1]; bi[1]++;
257 *(cv++) = *bi[2]; bi[2]++;
268 glRasterPos3f(x,y,0.0f);
269 glDrawPixels(image[0].getSizeX(),
284 int height = img.getHeight();
285 int width = img.getWidth();
286 int size = width*height;
287 byte *imgdat = (
byte*)img.getData();
291 for(vector<
Image<byte> >::iterator ii = dimg.begin();
292 ii!=dimg.end(); ii++)
293 ii->setSize(width, height);
296 for(
int i=size;i>0;i--,imgdat+=nchan,sind++)
298 for(
int c=0; c<nchan; c++) {
299 dimg[c][sind] = imgdat[c];
308 int height = img.getHeight();
309 int width = img.getWidth();
310 int size = width*height;
311 byte *imgdat = (
byte*)img.getData();
315 for(
int i=size;i>0;i--,imgdat+=nchan,htimg++)
328 int height = img.getHeight();
329 int width = img.getWidth();
331 int size = width*height;
332 byte *imgdat = (
byte*)img.getData();
335 for(
int i=size;i>0;i--,imgdat+=nchan,htimg++)
349 for(
int j=0; j<nimg.
getSizeY(); j++)
350 for(
int i=0; i<nimg.
getSizeX(); i++, data++)
byte * interleave(const vector< Image< byte > > &img)
std::vector< ByteImage > data
static bool loadImage(std::vector< Image< byte > > &image, const char *filename)
static void drawImage(const std::vector< Image< byte > > &image, float x=0, float y=0, float sx=1.0f, float sy=1.0f)
static void copyImage2FXImage(FXImage &img, const vector< Image< byte > > &dimg)
void setImage(const Image< byte > &image)
void draw(float x, float y, float sx=1.f, float sy=1.f) const
void setID(const std::string &id)
virtual bool performUpdate()
bool load(const char *filename, dword ppmm=0)
void draw(float x=0, float y=0, float sx=1.0f, float sy=1.0f) const
Image< T > & makeNoiseImage(Image< T > &nimg, T mean, T sigma)
void addNoise(float sigma)
int m_CurrImage
current image
void setSize(int nx, int ny)
void insert(const Image< T > &ii, const int x=0, const int y=0)
const T * getData() const
Dataset & copyData(const Dataset &rhs)
void setModified(dword mask=UPD_ALL)
static void copyFXImage2Image(vector< Image< byte > > &dimg, const FXImage &img)