mirror of https://github.com/fltk/fltk.git
Browse Source
The pixmap_browser demo now supports all image formats via Fl_Shared_Image. Dropped image file stuff from image demo. Added Fl_Tiled_Image class, which tiles an Fl_Image, useful for tiling a background image in groups. Added tiled_image demo. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1725 ea41ed52-d2ee-0310-a9c1-e6b18d33e121pull/168/head
18 changed files with 982 additions and 146 deletions
@ -0,0 +1,41 @@ |
|||||||
|
//
|
||||||
|
// "$Id: Fl_PNM_Image.H,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $"
|
||||||
|
//
|
||||||
|
// PNM image header file for the Fast Light Tool Kit (FLTK).
|
||||||
|
//
|
||||||
|
// Copyright 1998-2001 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef Fl_PNM_Image_H |
||||||
|
#define Fl_PNM_Image_H |
||||||
|
# include "Fl_Image.H" |
||||||
|
|
||||||
|
class FL_EXPORT Fl_PNM_Image : public Fl_RGB_Image { |
||||||
|
|
||||||
|
public: |
||||||
|
|
||||||
|
Fl_PNM_Image(const char* filename); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: Fl_PNM_Image.H,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $".
|
||||||
|
//
|
@ -0,0 +1,41 @@ |
|||||||
|
//
|
||||||
|
// "$Id: Fl_XBM_Image.H,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $"
|
||||||
|
//
|
||||||
|
// XBM image header file for the Fast Light Tool Kit (FLTK).
|
||||||
|
//
|
||||||
|
// Copyright 1998-2001 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef Fl_XBM_Image_H |
||||||
|
#define Fl_XBM_Image_H |
||||||
|
# include "Fl_Bitmap.H" |
||||||
|
|
||||||
|
class FL_EXPORT Fl_XBM_Image : public Fl_Bitmap { |
||||||
|
|
||||||
|
public: |
||||||
|
|
||||||
|
Fl_XBM_Image(const char* filename); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // !Fl_XBM_Image_H
|
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: Fl_XBM_Image.H,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $".
|
||||||
|
//
|
@ -0,0 +1,41 @@ |
|||||||
|
//
|
||||||
|
// "$Id: Fl_XPM_Image.H,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $"
|
||||||
|
//
|
||||||
|
// XPM image header file for the Fast Light Tool Kit (FLTK).
|
||||||
|
//
|
||||||
|
// Copyright 1998-2001 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef Fl_XPM_Image_H |
||||||
|
#define Fl_XPM_Image_H |
||||||
|
# include "Fl_Pixmap.H" |
||||||
|
|
||||||
|
class FL_EXPORT Fl_XPM_Image : public Fl_Pixmap { |
||||||
|
|
||||||
|
public: |
||||||
|
|
||||||
|
Fl_XPM_Image(const char* filename); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // !Fl_XPM_Image
|
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: Fl_XPM_Image.H,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $".
|
||||||
|
//
|
@ -0,0 +1,161 @@ |
|||||||
|
//
|
||||||
|
// "$Id: Fl_PNM_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $"
|
||||||
|
//
|
||||||
|
// Fl_PNM_Image routines.
|
||||||
|
//
|
||||||
|
// Copyright 1997-2001 by Easy Software Products.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
// Contents:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Include necessary header files...
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <FL/Fl.H> |
||||||
|
#include <FL/Fl_PNM_Image.H> |
||||||
|
#include "config.h" |
||||||
|
#include <stdio.h> |
||||||
|
#include <stdlib.h> |
||||||
|
#include <string.h> |
||||||
|
#include <ctype.h> |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_PNM_Image::Fl_PNM_Image()' - Load a PNM image...
|
||||||
|
//
|
||||||
|
|
||||||
|
Fl_PNM_Image::Fl_PNM_Image(const char *name) // I - File to read
|
||||||
|
: Fl_RGB_Image(0,0,0) { |
||||||
|
FILE *fp; // File pointer
|
||||||
|
int x, y; // Looping vars
|
||||||
|
char line[1024], // Input line
|
||||||
|
*lineptr; // Pointer in line
|
||||||
|
uchar *ptr, // Pointer to pixel values
|
||||||
|
byte, // Byte from file
|
||||||
|
bit; // Bit in pixel
|
||||||
|
int format, // Format of PNM file
|
||||||
|
val, // Pixel value
|
||||||
|
maxval; // Maximum pixel value
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read the file header in the format:
|
||||||
|
//
|
||||||
|
// Pformat
|
||||||
|
// # comment1
|
||||||
|
// # comment2
|
||||||
|
// ...
|
||||||
|
// # commentN
|
||||||
|
// width
|
||||||
|
// height
|
||||||
|
// max sample
|
||||||
|
//
|
||||||
|
|
||||||
|
lineptr = fgets(line, sizeof(line), fp); |
||||||
|
lineptr ++; |
||||||
|
|
||||||
|
format = atoi(lineptr); |
||||||
|
while (isdigit(*lineptr)) lineptr ++; |
||||||
|
|
||||||
|
while (lineptr != NULL && w() == 0) { |
||||||
|
if (*lineptr == '\0' || *lineptr == '#') { |
||||||
|
lineptr = fgets(line, sizeof(line), fp); |
||||||
|
} else if (isdigit(*lineptr)) { |
||||||
|
w(atoi(lineptr)); |
||||||
|
while (isdigit(*lineptr)) lineptr ++; |
||||||
|
} else lineptr ++; |
||||||
|
} |
||||||
|
|
||||||
|
while (lineptr != NULL && h()) { |
||||||
|
if (*lineptr == '\0' || *lineptr == '#') { |
||||||
|
lineptr = fgets(line, sizeof(line), fp); |
||||||
|
} else if (isdigit(*lineptr)) { |
||||||
|
h(atoi(lineptr)); |
||||||
|
while (isdigit(*lineptr)) lineptr ++; |
||||||
|
} else lineptr ++; |
||||||
|
} |
||||||
|
|
||||||
|
if (format != 1 && format != 4) { |
||||||
|
maxval = 0; |
||||||
|
|
||||||
|
while (lineptr != NULL && maxval == 0) { |
||||||
|
if (*lineptr == '\0' || *lineptr == '#') { |
||||||
|
lineptr = fgets(line, sizeof(line), fp); |
||||||
|
} else if (isdigit(*lineptr)) { |
||||||
|
maxval = atoi(lineptr); |
||||||
|
while (isdigit(*lineptr)) lineptr ++; |
||||||
|
} else lineptr ++; |
||||||
|
} |
||||||
|
} else maxval = 1; |
||||||
|
|
||||||
|
// Allocate memory...
|
||||||
|
if (format == 1 || format == 2 || format == 4 || format == 5) d(1); |
||||||
|
else d(3); |
||||||
|
|
||||||
|
array = new uchar[w() * h() * d()]; |
||||||
|
|
||||||
|
// Read the image file...
|
||||||
|
for (y = 0; y < h(); y ++) { |
||||||
|
ptr = (uchar *)array + y * w() * d(); |
||||||
|
|
||||||
|
switch (format) { |
||||||
|
case 1 : |
||||||
|
case 2 : |
||||||
|
for (x = w(); x > 0; x --) |
||||||
|
if (fscanf(fp, "%d", &val) == 1) *ptr++ = 255 * val / maxval; |
||||||
|
break; |
||||||
|
|
||||||
|
case 3 : |
||||||
|
for (x = w(); x > 0; x --) { |
||||||
|
if (fscanf(fp, "%d", &val) == 1) *ptr++ = 255 * val / maxval; |
||||||
|
if (fscanf(fp, "%d", &val) == 1) *ptr++ = 255 * val / maxval; |
||||||
|
if (fscanf(fp, "%d", &val) == 1) *ptr++ = 255 * val / maxval; |
||||||
|
} |
||||||
|
break; |
||||||
|
|
||||||
|
case 4 : |
||||||
|
for (x = w(), byte = getc(fp), bit = 128; x > 0; x --) { |
||||||
|
if (byte & bit) *ptr++ = 255; |
||||||
|
else *ptr++ = 0; |
||||||
|
|
||||||
|
if (bit > 1) bit >>= 1; |
||||||
|
else { |
||||||
|
bit = 128; |
||||||
|
byte = getc(fp); |
||||||
|
} |
||||||
|
} |
||||||
|
break; |
||||||
|
|
||||||
|
case 5 : |
||||||
|
case 6 : |
||||||
|
fread(ptr, w(), d(), fp); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fclose(fp); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: Fl_PNM_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $".
|
||||||
|
//
|
@ -0,0 +1,133 @@ |
|||||||
|
//
|
||||||
|
// "$Id: Fl_Tiled_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $"
|
||||||
|
//
|
||||||
|
// Tiled image code for the Fast Light Tool Kit (FLTK).
|
||||||
|
//
|
||||||
|
// Copyright 1998-2001 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <FL/Fl.H> |
||||||
|
#include <FL/Fl_Tiled_Image.H> |
||||||
|
#include <FL/fl_draw.H> |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_Tiled_Image::Fl_Tiled_Image()' - Constructor.
|
||||||
|
//
|
||||||
|
// Use a width and height of 0 to tile the whole window/widget.
|
||||||
|
//
|
||||||
|
|
||||||
|
Fl_Tiled_Image::Fl_Tiled_Image(Fl_Image *i, // I - Image to tile
|
||||||
|
int W, // I - Width of tiled area
|
||||||
|
int H) : // I - Height of tiled area
|
||||||
|
Fl_Image(W,H,0) { |
||||||
|
image_ = i; |
||||||
|
alloc_image_ = 0; |
||||||
|
|
||||||
|
if (W == 0) w(Fl::w()); |
||||||
|
if (H == 0) h(Fl::h()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_Tiled_Image::~Fl_Tiled_Image()' - Destructor.
|
||||||
|
//
|
||||||
|
|
||||||
|
Fl_Tiled_Image::~Fl_Tiled_Image() { |
||||||
|
if (alloc_image_) delete image_; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_Tiled_Image::copy()' - Copy and resize a tiled image...
|
||||||
|
//
|
||||||
|
|
||||||
|
Fl_Image * // O - New image
|
||||||
|
Fl_Tiled_Image::copy(int W, // I - New width
|
||||||
|
int H) { // I - New height
|
||||||
|
if (W == w() && H == h()) return this; |
||||||
|
else return new Fl_Tiled_Image(image_, W, H); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_Tiled_Image::color_average()' - Blend colors...
|
||||||
|
//
|
||||||
|
|
||||||
|
void |
||||||
|
Fl_Tiled_Image::color_average(Fl_Color c, // I - Color to blend with
|
||||||
|
float i) { // I - Blend fraction
|
||||||
|
Fl_Image *temp = image_->copy(); |
||||||
|
|
||||||
|
temp->color_average(c, i); |
||||||
|
|
||||||
|
image_ = temp; |
||||||
|
alloc_image_ = 1; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_Tiled_Image::desaturate()' - Convert the image to grayscale...
|
||||||
|
//
|
||||||
|
|
||||||
|
void |
||||||
|
Fl_Tiled_Image::desaturate() { |
||||||
|
Fl_Image *temp = image_->copy(); |
||||||
|
|
||||||
|
temp->desaturate(); |
||||||
|
|
||||||
|
image_ = temp; |
||||||
|
alloc_image_ = 1; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_Tiled_Image::draw()' - Draw a shared image...
|
||||||
|
//
|
||||||
|
|
||||||
|
void |
||||||
|
Fl_Tiled_Image::draw(int X, // I - Starting X position
|
||||||
|
int Y, // I - Starting Y position
|
||||||
|
int W, // I - Width of area to be filled
|
||||||
|
int H, // I - Height of area to be filled
|
||||||
|
int cx, // I - "Source" X position
|
||||||
|
int cy) { // I - "Source" Y position
|
||||||
|
if (!image_->w() || !image_->h()) return; |
||||||
|
if (W == 0) W = Fl::w(); |
||||||
|
if (H == 0) H = Fl::h(); |
||||||
|
|
||||||
|
X += cx; |
||||||
|
Y += cy; |
||||||
|
|
||||||
|
X = X - (X % image_->w()); |
||||||
|
Y = Y - (Y % image_->h()); |
||||||
|
|
||||||
|
W += X; |
||||||
|
H += Y; |
||||||
|
|
||||||
|
for (int yy = Y; yy < H; yy += image_->h()) |
||||||
|
for (int xx = X; xx < W; xx += image_->w()) |
||||||
|
image_->draw(xx, yy); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: Fl_Tiled_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $".
|
||||||
|
//
|
@ -0,0 +1,88 @@ |
|||||||
|
//
|
||||||
|
// "$Id: Fl_XBM_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $"
|
||||||
|
//
|
||||||
|
// Fl_XBM_Image routines.
|
||||||
|
//
|
||||||
|
// Copyright 1997-2001 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
// Contents:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Include necessary header files...
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <FL/Fl.H> |
||||||
|
#include <FL/Fl_XBM_Image.H> |
||||||
|
#include "config.h" |
||||||
|
#include <stdio.h> |
||||||
|
#include <stdlib.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
Fl_XBM_Image::Fl_XBM_Image(const char *name) : Fl_Bitmap((const char *)0,0,0) { |
||||||
|
FILE *f; |
||||||
|
uchar *data; |
||||||
|
|
||||||
|
if ((f = fopen(name, "rb")) == NULL) return; |
||||||
|
|
||||||
|
char buffer[1024]; |
||||||
|
char junk[1024]; |
||||||
|
int wh[2]; // width and height
|
||||||
|
int i; |
||||||
|
for (i = 0; i<2; i++) { |
||||||
|
for (;;) { |
||||||
|
if (!fgets(buffer,1024,f)) return; |
||||||
|
int r = sscanf(buffer,"#define %s %d",junk,&wh[i]); |
||||||
|
if (r >= 2) break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// skip to data array:
|
||||||
|
for (;;) { |
||||||
|
if (!fgets(buffer,1024,f)) return; |
||||||
|
if (!strncmp(buffer,"static ",7)) break; |
||||||
|
} |
||||||
|
|
||||||
|
// Allocate memory...
|
||||||
|
w(wh[0]); |
||||||
|
h(wh[1]); |
||||||
|
|
||||||
|
int n = ((wh[0]+7)/8)*wh[1]; |
||||||
|
array = new uchar[((w() + 7) / 8) * h()]; |
||||||
|
|
||||||
|
// read the data:
|
||||||
|
for (i = 0, data = (uchar *)array; i < n;) { |
||||||
|
if (!fgets(buffer,1024,f)) return; |
||||||
|
const char *a = buffer; |
||||||
|
while (*a && i<n) { |
||||||
|
int t; |
||||||
|
if (sscanf(a," 0x%x",&t)>0) *data++ = t; |
||||||
|
while (*a && *a++ != ','); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fclose(f); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: Fl_XBM_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $".
|
||||||
|
//
|
@ -0,0 +1,129 @@ |
|||||||
|
//
|
||||||
|
// "$Id: Fl_XPM_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $"
|
||||||
|
//
|
||||||
|
// Fl_XPM_Image routines.
|
||||||
|
//
|
||||||
|
// Copyright 1997-2001 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
// Contents:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Include necessary header files...
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <FL/Fl.H> |
||||||
|
#include <FL/Fl_XPM_Image.H> |
||||||
|
#include "config.h" |
||||||
|
#include <stdio.h> |
||||||
|
#include <stdlib.h> |
||||||
|
#include <string.h> |
||||||
|
#include <ctype.h> |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'hexdigit()' - Convert a hex digit to an integer.
|
||||||
|
//
|
||||||
|
|
||||||
|
static int hexdigit(int x) { // I - Hex digit...
|
||||||
|
if (isdigit(x)) return x-'0'; |
||||||
|
if (isupper(x)) return x-'A'+10; |
||||||
|
if (islower(x)) return x-'a'+10; |
||||||
|
return 20; |
||||||
|
} |
||||||
|
|
||||||
|
#define MAXSIZE 2048 |
||||||
|
#define INITIALLINES 256 |
||||||
|
|
||||||
|
Fl_XPM_Image::Fl_XPM_Image(const char *name) : Fl_Pixmap((char *const*)0) { |
||||||
|
FILE *f; |
||||||
|
|
||||||
|
if ((f = fopen(name, "rb")) == NULL) return; |
||||||
|
|
||||||
|
// read all the c-strings out of the file:
|
||||||
|
char** new_data = new char *[INITIALLINES]; |
||||||
|
char** temp_data; |
||||||
|
int malloc_size = INITIALLINES; |
||||||
|
char buffer[MAXSIZE+20]; |
||||||
|
int i = 0; |
||||||
|
while (fgets(buffer,MAXSIZE+20,f)) { |
||||||
|
if (buffer[0] != '\"') continue; |
||||||
|
char *myp = buffer; |
||||||
|
char *q = buffer+1; |
||||||
|
while (*q != '\"' && myp < buffer+MAXSIZE) { |
||||||
|
if (*q == '\\') switch (*++q) { |
||||||
|
case '\r': |
||||||
|
case '\n': |
||||||
|
fgets(q,(buffer+MAXSIZE+20)-q,f); break; |
||||||
|
case 0: |
||||||
|
break; |
||||||
|
case 'x': { |
||||||
|
q++; |
||||||
|
int n = 0; |
||||||
|
for (int x = 0; x < 3; x++) { |
||||||
|
int d = hexdigit(*q); |
||||||
|
if (d > 15) break; |
||||||
|
n = (n<<4)+d; |
||||||
|
q++; |
||||||
|
} |
||||||
|
*myp++ = n; |
||||||
|
} break; |
||||||
|
default: { |
||||||
|
int c = *q++; |
||||||
|
if (c>='0' && c<='7') { |
||||||
|
c -= '0'; |
||||||
|
for (int x=0; x<2; x++) { |
||||||
|
int d = hexdigit(*q); |
||||||
|
if (d>7) break; |
||||||
|
c = (c<<3)+d; |
||||||
|
q++; |
||||||
|
} |
||||||
|
} |
||||||
|
*myp++ = c; |
||||||
|
} break; |
||||||
|
} else { |
||||||
|
*myp++ = *q++; |
||||||
|
} |
||||||
|
} |
||||||
|
*myp++ = 0; |
||||||
|
if (i >= malloc_size) { |
||||||
|
temp_data = new char *[malloc_size + INITIALLINES]; |
||||||
|
memcpy(temp_data, new_data, sizeof(char *) * malloc_size); |
||||||
|
delete[] new_data; |
||||||
|
new_data = temp_data; |
||||||
|
malloc_size += INITIALLINES; |
||||||
|
} |
||||||
|
new_data[i] = new char[myp-buffer+1]; |
||||||
|
memcpy(new_data[i], buffer,myp-buffer); |
||||||
|
new_data[i][myp-buffer] = 0; |
||||||
|
i++; |
||||||
|
} |
||||||
|
|
||||||
|
fclose(f); |
||||||
|
|
||||||
|
data(new_data, i); |
||||||
|
measure(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: Fl_XPM_Image.cxx,v 1.1.2.1 2001/11/24 18:07:57 easysw Exp $".
|
||||||
|
//
|
@ -0,0 +1,120 @@ |
|||||||
|
/* XPM */ |
||||||
|
static char * tile_xpm[] = { |
||||||
|
"100 100 17 1", |
||||||
|
" c None", |
||||||
|
". c #565656", |
||||||
|
"+ c #888888", |
||||||
|
"@ c #A8A8A8", |
||||||
|
"# c #8E8E8E", |
||||||
|
"$ c #A0A0A0", |
||||||
|
"% c #6E6E6E", |
||||||
|
"& c #727272", |
||||||
|
"* c #BFBFBF", |
||||||
|
"= c #989898", |
||||||
|
"- c #767676", |
||||||
|
"; c #7A7A7A", |
||||||
|
"> c #B4B4B4", |
||||||
|
", c #808080", |
||||||
|
"' c #AEAEAE", |
||||||
|
") c #656565", |
||||||
|
"! c #929292", |
||||||
|
"$=>$@@,++,,,-;%$$+,;+)#;*!+,+@*!,!++;+;$@;+==,#=!!$--%)++=$,!@!%#+@!>$=!+*!=%)==>>@+,$==@!))#$%;=!!*", |
||||||
|
"++$-,>$@!;+;-&++-,#!;++!-+#+!@$$#,,+&#=$=!==$+$#=>>>,&$#&$$#>$=,+.-''!$'*=+>+);+>*@$=--=$=,+!==,,@==", |
||||||
|
"!$,-,=@=$+==,+!%,#,-&=$++-)===#+##,+=+=#$@$=>''$$*@=,+#!,$=>!=$+)++)+*@=$@=,+$$$+!'**#,,,$+,=@=;==-;", |
||||||
|
"!,###$$);'#;$=+%;+#;++%-,=,==!)+#===========@>>>*>@!==#,+#==@$===+-;%@$=#+*>=!$$$==,*>@-+;+#$,%,@@%#", |
||||||
|
"+@,!=,,+!$==$++!&;+#!,%),=>!+;,=+$@=+!$==+#$!@>>>*@=;!,+#!==$$>@$!=>=$@$=+@='$!+@*+!!=*@$+,'@+%+,,@=", |
||||||
|
"=;&+,.-!=!=!=;+!!,!=!;)-==,++;+@>@+,#=$+!'$=#='>=*$$!+,!,#$$@!>$,#+$@@$@'@##==@$=+'$!+!$>@@*+!*+,!=!", |
||||||
|
"!!,,,+++&#=,+!,'!,!##!$$!-.++=@'=$$!==++==@=@>=!@@!#!+$+$===$@#+=$!=@$!@=#@+$>!=@$=!@'!=$*@$$!!====$", |
||||||
|
"#%)#@@+%,+!$,++=#+++,=$+-+++!$!+==$$===#+##$=@$=+$$+#=!@=,+$#!$$$$=$==$=!,,$@*$,=>-=@#$>>$+'>$@=>'!+", |
||||||
|
"),,-=+$!@##-,,!;,=++$@;%&,!!=$#!=!@@$$$,+==+$!==+!$$=#+!+!!+=!$!@@$=++=>!&+@$==!!!+==$*==$*@=@**$+!+", |
||||||
|
"!'$#,,,@$#+&)&-;===$,%;+#!==###$=#==!===>>+====$$,$$=+=-,$=;#!==$=#=;+=@===$$$=#$+=@@>$+>*@$'*@-+=%,", |
||||||
|
"$$$@++!!#%)+,%++>=$#%%#%=@=+=;,@$+=+=>$=='!+!##+$$!!;!=&=!##@$,+@+=+!$+-=@$,=>'+#!=@@==@>''@>>-+>$$=", |
||||||
|
"=,%++,@!,)),%,+=@!%++!+#,#+$=$!!='==@$$==+#$++,$$!@#$=,@+,,@#$+#=$$=!$+!+=!$$>==$$;=@!=$@*>@$==='$=$", |
||||||
|
"$$=&%#+,!=!+,;-+-%)#=@=+%%$$#!@!@$@@@>=,+!!,,#=>@$!#$;#$=-$@+;$*$!$@,&=$++!!+@@==#=!@;$>*@++@>=+,>>$", |
||||||
|
"$$#=$,+%,!@@!!&%-,,++==,,+!!#,#$!@@$=@#==#@=#=$*$$@,,+!+#!+=%,=@$'$$$=+!+==+#-=@,+$+@>!#=@$!@!=$=+#!", |
||||||
|
"+#=>==;,++,=>!;-,,;-#++$@!$,,!==@>>@$!=+$#+@='@$!'@$$&+#+=#+;+#=!'>$$@!#$++!=-!;,$!+>*'=#!@@@-##@$#+", |
||||||
|
",,#=$!$#+%,,,!=+=,!-,+!!$=%,+$!#@@'@$@,+$=+!=$>$!@+;@+,,#=;$=!,++>$=>$$=!,+==,-+@=!$@!@>@$-,,==!=$!!", |
||||||
|
"!+=$=,$#-#+=!,!=!=++;;,=;,=!+=+!,+$+#>=+@@####@=@@+;,+&;-==$#$=#$@=#@*==!=;+++==!!$@#%>>$=!#,-#+#+,)", |
||||||
|
"+&$=!&;###@=#-,@,,!+;!,%+!=!!++,+++=+'>==@#==-=$!$#!-,)+!#!==+$$@=#==,=@!==!%++==='@==$$=##!+!+%-=$$", |
||||||
|
"+!#=+-,,=@++==+#,--+++&+!!===+!+#;$=++*$$=!=@@=+=#%$--!+,@$+#+'>!=!+!!===$=$;++#,$+=@'=-!#!#=!+=,%!,", |
||||||
|
"+@$-+!)#=,=$!==,;,+-%,!!#@!$!-#-$!=+==#+$=+!='@$#++-;!!+$,!#-@'$++++==!$+!#=!+$@$,#==#+#==@!,%$==!,%", |
||||||
|
"#+#+,!,+%+@$>!!,;+;%+#++=+,$+-&=+,@$%!==-#,*@;$$=!+=,=#!!@$#$>!+$=!=#!@==!,,===$==!=@++,+@@$!==;,=#$", |
||||||
|
",=+,#$!;,@=+$'$$!+%;,-,##+,+,=!,,+++&==!=!$>@=$!,$!'#@#,!@!@==!+$+$!$=#$,+$!==++,=!@+!=!,!$+$+,=$,!#", |
||||||
|
")+>@$$+,=#+=#!+$=!,,&,;=++#!+,,++=##!-&+@$@@$$$,@$',&@*=-!=@!=,;=$#=@!++#!$'=!=,,+=$===;=$$=!=+!@=$%", |
||||||
|
"#+#@@@=>'#=,,#!,$=$+,,+$+$,;+--!$!!#=#,-,=$=$$,=@=,+$'$+,++=@;##-!@==+!!=!#@==,,+==!+!++=='$=>$#;@!;", |
||||||
|
";++=>+=@!$$$!,#!&,==!#@-!!-&%-&;===$+,)%,,+'$$@!++==*=%@+#=!==!==$+$$=,#$=!=,++=!$#-!@=!;$==@@>#+!+)", |
||||||
|
"+,+@!$==,=@=++=,&+-$!#@=,-,--+)#!,$'=%;-%;$@#@$!+!>>,#@$;+$$!=!@>$$=!,+>!!$-+,#!++,+!=+=+=-!>$@@$=;;", |
||||||
|
"+;$$=+$#=@!=$,,!#;,,+=#=++,!+&+#+;+$#+=,%!+;,==!=*=&$$!,+#'+,@@>=@$$,+$+#!!+,++#%%$$,++!=!==,#>$-=*@", |
||||||
|
"+>>+&=,=$+$@$%-!+++,&#+-+,=$+-$+;;=%,=@+$++&#+;,*$-%$$+,,;$$$=!$#$@+$@=$>,++$!,)-!!!+#;@+#@,!=#@=@>$", |
||||||
|
"'>$#%!$#,>$#=$,&&++%$#%#=+;!$$#%-+%,=!-!=+!=#+,#!$-'$=+,=@!=!@$#$!+!$!$*',,##+#+!!,;+#+=@##=@+@*'=!$", |
||||||
|
"@@=)$$=!=$$$=+=#,--!;-!+!#+++;=!+;!++++%)$=#@@+!,,!'='=+'!++=@!+=#=$=#$++#,,%=+=#!#&,!#====$$**@++@@", |
||||||
|
"@=+>>#==$==+!#=$+;+),++#+$>+;,+$!=#+==&+-#-$*+>==+,+$!+=+,@@@$=;=@$!+==&@+,+-,+;+,#+=$=!@@=='$=@''$+", |
||||||
|
"$)+@@'>$++,+#$$#!=+,-+-+==$#=!=++=#+#$==@,,>#@,$@+$%;,@!;=+,+=$$=##+==##='#,&+=&%+##$@@=$==$@=@$@$!$", |
||||||
|
"@>'@=@>$+=+,!==!!##!=+;-+#=++,%@=-,=;;=@!=>$$@$&,!@#!;!='++!+$@#+,+,-#!++!$,+$+),##'>,++$$=$@@'=!,$,", |
||||||
|
"$$>*@>==#=#++==$$+#='=+,#$#=&)+,=+!!%+$,='=@>=+,*;)!+=$$,%++@$)%;+==,#+-++-,$#+&++$=+#$-!=@''@=;#,;-", |
||||||
|
"*>+=$#++@=,=;,==,#;$=+++=!=+;-,-!=#&!>%+=,@$+;$$-&&-$=@$#,-,#+--$,%-,!,+%;=$--!$=$=#!$##+$@$==!=&&-$", |
||||||
|
"'=$$,-=+,#$!==+!+++!@!=$+=+,-!,;$=-$=,=+,$>--=@+)%!!@#++$@$,-+-=$+%&!&;,==$+++$=$=+#==+!!@=!;$#+$$>>", |
||||||
|
",#=+!$-%)#==>$$,,!+=''++$+,#,##%%+@$,,,,@@#==@=,%,$$$#+;=+=$!++,-,;+,%%!@,-,,=!==!+#+==#+=+),==$='>+", |
||||||
|
"$+#==$);,++#=$=,=#$$==$$$!#;=+#++$',#=!==+=$=+#$#!!$#=+,!--$@+-&)-+!%)!=+--!=@=##=!$=@===!&+$#$@@=,@", |
||||||
|
"$$$@+++;%+=,=!=$$$$=!=$#'==#,,+!$=!=,!==@=@*=$,==$,@==,++,+=;-=!+%+%%=+&%++=$!$-++=+@$++!+++$#==++#-", |
||||||
|
"+=$=+=;=-#,+,,$=$'@#@=+%-@>!#,$$+@#==%,!$@'@=$$=@!!+,--=##!!,)=@#=)%,,-,+==!!,,++=+$+,!;,++=,+#%,!;+", |
||||||
|
"$+#'$,,+@!=%,,+!'@>@##=$+;%=@$!!$=+=$,===++!+$@*$#=,#,-==+&,!==$=+=!!%,&===!;+!#=;#!+,!+=-;+==-)#+,,", |
||||||
|
"+==#=$+=,,++,,+!=@$+$>$+#,==;*@=!#$-,>$'@%&->=>>$$;,!++=+,+,+@#=!#@++,#=!=+,+,+==-+-##+#,-,;-##+#!,+", |
||||||
|
"+=%,@=!+-&&==!$=,@$'=++=#;+$'==;+=$&!$+#'#$@$#@>=++,#$$+)++;!#=!!+,,,$'=&,+++,#=++=$===;=#,+#+!+#!#,", |
||||||
|
";,,!!##,,,,==@$,=+$>+#$$+=$#@=-!$=;$#$$,-!'$#=#$$;+#!++=+;&;-+'$&;,+,,&$$==+!#,++==#-=!+++,+!!$$==--", |
||||||
|
"&-,!!=;+=++$$=#@$=@,+=$=$!=#+,$+=;,==!$+==@>@,&,$'++#,)++=,,)+=,!$=#-.&+#$'@!+++==!+,+&#!,++$=+!@=-=", |
||||||
|
"&+!+;,+++!!$$##$$!=$=!+=!=!!;!@=-++@$@$'$#>'++$$$+$-%,=--+!+@+;!#;#;%-&,#=$@@!!=$,=!;)&++=!#$#,&++!!", |
||||||
|
"$=!,))-,!=,-$$@=+!+!,'=+==!=$+=++,=+'@'@@===;,!>'@+),=&+$,)=+++-+,);;%-,++$#+=@$#,+$,#=+!+!##+#;,+#%", |
||||||
|
"!#-%%%;#+;!%!@=@@+.$;+*@+=,@!;%$=+,=$,@$,=>+#;+=@$$@=%=>@-,);!$$&);#),,#,%&#!==@>++,=>=+++,,!=--=#,@", |
||||||
|
"#&%,=,##.+%!+=$$+=@!!+-,=@!$#,,$!=@#@=!,+@@###+-=#@,-=$,#++)-#$#-#)#,,%,;),!$!##$@'$!$!,+!!!+-;#+#$$", |
||||||
|
";.%.-+$@&)-!=++@##=*$,!=$;+@='!!-!>#!!!$>%+-&#!=$!#=$*$#-+%=;!=-!+#;#++&),==+$+!$++=-,#++!+$+%$%;++;", |
||||||
|
"$--%)++=$,!@!%#+@!>$=!+*!=%)==>>@+,$==@!))#$%;=!!*$=>$@@,++,,,-;%$$+,;+)#;*!+,+@*!,!++;+;$@;+==,#=!!", |
||||||
|
">>,&$#&$$#>$=,+.-''!$'*=+>+);+>*@$=--=$=,+!==,,@==++$-,>$@!;+;-&++-,#!;++!-+#+!@$$#,,+&#=$=!==$+$#=>", |
||||||
|
"@=,+#!,$=>!=$+)++)+*@=$@=,+$$$+!'**#,,,$+,=@=;==-;!$,-,=@=$+==,+!%,#,-&=$++-)===#+##,+=+=#$@$=>''$$*", |
||||||
|
"@!==#,+#==@$===+-;%@$=#+*>=!$$$==,*>@-+;+#$,%,@@%#!,###$$);'#;$=+%;+#;++%-,=,==!)+#===========@>>>*>", |
||||||
|
"@=;!,+#!==$$>@$!=>=$@$=+@='$!+@*+!!=*@$+,'@+%+,,@=+@,!=,,+!$==$++!&;+#!,%),=>!+;,=+$@=+!$==+#$!@>>>*", |
||||||
|
"$$!+,!,#$$@!>$,#+$@@$@'@##==@$=+'$!+!$>@@*+!*+,!=!=;&+,.-!=!=!=;+!!,!=!;)-==,++;+@>@+,#=$+!'$=#='>=*", |
||||||
|
"!#!+$+$===$@#+=$!=@$!@=#@+$>!=@$=!@'!=$*@$$!!====$!!,,,+++&#=,+!,'!,!##!$$!-.++=@'=$$!==++==@=@>=!@@", |
||||||
|
"$+#=!@=,+$#!$$$$=$==$=!,,$@*$,=>-=@#$>>$+'>$@=>'!+#%)#@@+%,+!$,++=#+++,=$+-+++!$!+==$$===#+##$=@$=+$", |
||||||
|
"$$=#+!+!!+=!$!@@$=++=>!&+@$==!!!+==$*==$*@=@**$+!+),,-=+$!@##-,,!;,=++$@;%&,!!=$#!=!@@$$$,+==+$!==+!", |
||||||
|
"$$=+=-,$=;#!==$=#=;+=@===$$$=#$+=@@>$+>*@$'*@-+=%,!'$#,,,@$#+&)&-;===$,%;+#!==###$=#==!===>>+====$$,", |
||||||
|
"!!;!=&=!##@$,+@+=+!$+-=@$,=>'+#!=@@==@>''@>>-+>$$=$$$@++!!#%)+,%++>=$#%%#%=@=+=;,@$+=+=>$=='!+!##+$$", |
||||||
|
"@#$=,@+,,@#$+#=$$=!$+!+=!$$>==$$;=@!=$@*>@$==='$=$=,%++,@!,)),%,+=@!%++!+#,#+$=$!!='==@$$==+#$++,$$!", |
||||||
|
"!#$;#$=-$@+;$*$!$@,&=$++!!+@@==#=!@;$>*@++@>=+,>>$$$=&%#+,!=!+,;-+-%)#=@=+%%$$#!@!@$@@@>=,+!!,,#=>@$", |
||||||
|
"@,,+!+#!+=%,=@$'$$$=+!+==+#-=@,+$+@>!#=@$!@!=$=+#!$$#=$,+%,!@@!!&%-,,++==,,+!!#,#$!@@$=@#==#@=#=$*$$", |
||||||
|
"@$$&+#+=#+;+#=!'>$$@!#$++!=-!;,$!+>*'=#!@@@-##@$#++#=>==;,++,=>!;-,,;-#++$@!$,,!==@>>@$!=+$#+@='@$!'", |
||||||
|
"+;@+,,#=;$=!,++>$=>$$=!,+==,-+@=!$@!@>@$-,,==!=$!!,,#=$!$#+%,,,!=+=,!-,+!!$=%,+$!#@@'@$@,+$=+!=$>$!@", |
||||||
|
"+;,+&;-==$#$=#$@=#@*==!=;+++==!!$@#%>>$=!#,-#+#+,)!+=$=,$#-#+=!,!=!=++;;,=;,=!+=+!,+$+#>=+@@####@=@@", |
||||||
|
"#!-,)+!#!==+$$@=#==,=@!==!%++==='@==$$=##!+!+%-=$$+&$=!&;###@=#-,@,,!+;!,%+!=!!++,+++=+'>==@#==-=$!$", |
||||||
|
"%$--!+,@$+#+'>!=!+!!===$=$;++#,$+=@'=-!#!#=!+=,%!,+!#=+-,,=@++==+#,--+++&+!!===+!+#;$=++*$$=!=@@=+=#", |
||||||
|
"+-;!!+$,!#-@'$++++==!$+!#=!+$@$,#==#+#==@!,%$==!,%+@$-+!)#=,=$!==,;,+-%,!!#@!$!-#-$!=+==#+$=+!='@$#+", |
||||||
|
"+=,=#!!@$#$>!+$=!=#!@==!,,===$==!=@++,+@@$!==;,=#$#+#+,!,+%+@$>!!,;+;%+#++=+,$+-&=+,@$%!==-#,*@;$$=!", |
||||||
|
"!'#@#,!@!@==!+$+$!$=#$,+$!==++,=!@+!=!,!$+$+,=$,!#,=+,#$!;,@=+$'$$!+%;,-,##+,+,=!,,+++&==!=!$>@=$!,$", |
||||||
|
"',&@*=-!=@!=,;=$#=@!++#!$'=!=,,+=$===;=$$=!=+!@=$%)+>@$$+,=#+=#!+$=!,,&,;=++#!+,,++=##!-&+@$@@$$$,@$", |
||||||
|
",+$'$+,++=@;##-!@==+!!=!#@==,,+==!+!++=='$=>$#;@!;#+#@@@=>'#=,,#!,$=$+,,+$+$,;+--!$!!#=#,-,=$=$$,=@=", |
||||||
|
"==*=%@+#=!==!==$+$$=,#$=!=,++=!$#-!@=!;$==@@>#+!+);++=>+=@!$$$!,#!&,==!#@-!!-&%-&;===$+,)%,,+'$$@!++", |
||||||
|
">>,#@$;+$$!=!@>$$=!,+>!!$-+,#!++,+!=+=+=-!>$@@$=;;+,+@!$==,=@=++=,&+-$!#@=,-,--+)#!,$'=%;-%;$@#@$!+!", |
||||||
|
"=&$$!,+#'+,@@>=@$$,+$+#!!+,++#%%$$,++!=!==,#>$-=*@+;$$=+$#=@!=$,,!#;,,+=#=++,!+&+#+;+$#+=,%!+;,==!=*", |
||||||
|
"-%$$+,,;$$$=!$#$@+$@=$>,++$!,)-!!!+#;@+#@,!=#@=@>$+>>+&=,=$+$@$%-!+++,&#+-+,=$+-$+;;=%,=@+$++&#+;,*$", |
||||||
|
"-'$=+,=@!=!@$#$!+!$!$*',,##+#+!!,;+#+=@##=@+@*'=!$'>$#%!$#,>$#=$,&&++%$#%#=+;!$$#%-+%,=!-!=+!=#+,#!$", |
||||||
|
"!'='=+'!++=@!+=#=$=#$++#,,%=+=#!#&,!#====$$**@++@@@@=)$$=!=$$$=+=#,--!;-!+!#+++;=!+;!++++%)$=#@@+!,,", |
||||||
|
",+$!+=+,@@@$=;=@$!+==&@+,+-,+;+,#+=$=!@@=='$=@''$+@=+>>#==$==+!#=$+;+),++#+$>+;,+$!=#+==&+-#-$*+>==+", |
||||||
|
"$%;,@!;=+,+=$$=##+==##='#,&+=&%+##$@@=$==$@=@$@$!$$)+@@'>$++,+#$$#!=+,-+-+==$#=!=++=#+#$==@,,>#@,$@+", |
||||||
|
"@#!;!='++!+$@#+,+,-#!++!$,+$+),##'>,++$$=$@@'=!,$,@>'@=@>$+=+,!==!!##!=+;-+#=++,%@=-,=;;=@!=>$$@$&,!", |
||||||
|
")!+=$$,%++@$)%;+==,#+-++-,$#+&++$=+#$-!=@''@=;#,;-$$>*@>==#=#++==$$+#='=+,#$#=&)+,=+!!%+$,='=@>=+,*;", |
||||||
|
"&-$=@$#,-,#+--$,%-,!,+%;=$--!$=$=#!$##+$@$==!=&&-$*>+=$#++@=,=;,==,#;$=+++=!=+;-,-!=#&!>%+=,@$+;$$-&", |
||||||
|
"!!@#++$@$,-+-=$+%&!&;,==$+++$=$=+#==+!!@=!;$#+$$>>'=$$,-=+,#$!==+!+++!@!=$+=+,-!,;$=-$=,=+,$>--=@+)%", |
||||||
|
"$$$#+;=+=$!++,-,;+,%%!@,-,,=!==!+#+==#+=+),==$='>+,#=+!$-%)#==>$$,,!+=''++$+,#,##%%+@$,,,,@@#==@=,%,", |
||||||
|
"!$#=+,!--$@+-&)-+!%)!=+--!=@=##=!$=@===!&+$#$@@=,@$+#==$);,++#=$=,=#$$==$$$!#;=+#++$',#=!==+=$=+#$#!", |
||||||
|
",@==,++,+=;-=!+%+%%=+&%++=$!$-++=+@$++!+++$#==++#-$$$@+++;%+=,=!=$$$$=!=$#'==#,,+!$=!=,!==@=@*=$,==$", |
||||||
|
"!+,--=##!!,)=@#=)%,,-,+==!!,,++=+$+,!;,++=,+#%,!;++=$=+=;=-#,+,,$=$'@#@=+%-@>!#,$$+@#==%,!$@'@=$$=@!", |
||||||
|
"=,#,-==+&,!==$=+=!!%,&===!;+!#=;#!+,!+=-;+==-)#+,,$+#'$,,+@!=%,,+!'@>@##=$+;%=@$!!$=+=$,===++!+$@*$#", |
||||||
|
";,!++=+,+,+@#=!#@++,#=!=+,+,+==-+-##+#,-,;-##+#!,++==#=$+=,,++,,+!=@$+$>$+#,==;*@=!#$-,>$'@%&->=>>$$", |
||||||
|
"+,#$$+)++;!#=!!+,,,$'=&,+++,#=++=$===;=#,+#+!+#!#,+=%,@=!+-&&==!$=,@$'=++=#;+$'==;+=$&!$+#'#$@$#@>=+", |
||||||
|
"+#!++=+;&;-+'$&;,+,,&$$==+!#,++==#-=!+++,+!!$$==--;,,!!##,,,,==@$,=+$>+#$$+=$#@=-!$=;$#$$,-!'$#=#$$;", |
||||||
|
"++#,)++=,,)+=,!$=#-.&+#$'@!+++==!+,+&#!,++$=+!@=-=&-,!!=;+=++$$=#@$=@,+=$=$!=#+,$+=;,==!$+==@>@,&,$'", |
||||||
|
"$-%,=--+!+@+;!#;#;%-&,#=$@@!!=$,=!;)&++=!#$#,&++!!&+!+;,+++!!$$##$$!=$=!+=!=!!;!@=-++@$@$'$#>'++$$$+", |
||||||
|
"+),=&+$,)=+++-+,);;%-,++$#+=@$#,+$,#=+!+!##+#;,+#%$=!,))-,!=,-$$@=+!+!,'=+==!=$+=++,=+'@'@@===;,!>'@", |
||||||
|
"$@=%=>@-,);!$$&);#),,#,%&#!==@>++,=>=+++,,!=--=#,@!#-%%%;#+;!%!@=@@+.$;+*@+=,@!;%$=+,=$,@$,=>+#;+=@$", |
||||||
|
"@,-=$,#++)-#$#-#)#,,%,;),!$!##$@'$!$!,+!!!+-;#+#$$#&%,=,##.+%!+=$$+=@!!+-,=@!$#,,$!=@#@=!,+@@###+-=#", |
||||||
|
"#=$*$#-+%=;!=-!+#;#++&),==+$+!$++=-,#++!+$+%$%;++;;.%.-+$@&)-!=++@##=*$,!=$;+@='!!-!>#!!!$>%+-&#!=$!"}; |
@ -0,0 +1,103 @@ |
|||||||
|
//
|
||||||
|
// "$Id: tiled_image.cxx,v 1.1.2.1 2001/11/24 18:07:58 easysw Exp $"
|
||||||
|
//
|
||||||
|
// Fl_Tiled_Image test program for the Fast Light Tool Kit (FLTK).
|
||||||
|
//
|
||||||
|
// Copyright 1998-2001 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
// USA.
|
||||||
|
//
|
||||||
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <FL/Fl.H> |
||||||
|
#include <FL/Fl_Window.H> |
||||||
|
#include <FL/Fl_Button.H> |
||||||
|
#include <FL/Fl_Pixmap.H> |
||||||
|
#include <FL/Fl_Tiled_Image.H> |
||||||
|
#include <stdio.h> |
||||||
|
#include <stdlib.h> |
||||||
|
#include <math.h> |
||||||
|
|
||||||
|
#include "tile.xpm" |
||||||
|
|
||||||
|
Fl_Button *b; |
||||||
|
Fl_Window *w; |
||||||
|
|
||||||
|
void button_cb(Fl_Widget *,void *) { |
||||||
|
w->hide(); |
||||||
|
} |
||||||
|
|
||||||
|
#include <FL/x.H> |
||||||
|
#ifndef WIN32 |
||||||
|
#include "list_visuals.cxx" |
||||||
|
#endif |
||||||
|
|
||||||
|
int visid = -1; |
||||||
|
int arg(int argc, char **argv, int &i) { |
||||||
|
if (argv[i][1] == 'v') { |
||||||
|
if (i+1 >= argc) return 0; |
||||||
|
visid = atoi(argv[i+1]); |
||||||
|
i += 2; |
||||||
|
return 2; |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
int main(int argc, char **argv) { |
||||||
|
#ifndef WIN32 |
||||||
|
int i = 1; |
||||||
|
|
||||||
|
Fl::args(argc,argv,i,arg); |
||||||
|
|
||||||
|
if (visid >= 0) { |
||||||
|
fl_open_display(); |
||||||
|
XVisualInfo templt; int num; |
||||||
|
templt.visualid = visid; |
||||||
|
fl_visual = XGetVisualInfo(fl_display, VisualIDMask, &templt, &num); |
||||||
|
if (!fl_visual) { |
||||||
|
fprintf(stderr, "No visual with id %d, use one of:\n",visid); |
||||||
|
list_visuals(); |
||||||
|
exit(1); |
||||||
|
} |
||||||
|
fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen), |
||||||
|
fl_visual->visual, AllocNone); |
||||||
|
fl_xpixel(FL_BLACK); // make sure black is allocated in overlay visuals
|
||||||
|
} else { |
||||||
|
Fl::visual(FL_RGB); |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
Fl_Window window(400,400); ::w = &window; |
||||||
|
Fl_Group group(0,0,400,400); |
||||||
|
group.image(new Fl_Tiled_Image(new Fl_Pixmap(tile_xpm))); |
||||||
|
group.align(FL_ALIGN_INSIDE); |
||||||
|
|
||||||
|
Fl_Button b(340,365,50,25,"Close"); ::b = &b; |
||||||
|
b.callback(button_cb); |
||||||
|
|
||||||
|
group.end(); |
||||||
|
|
||||||
|
window.resizable(group); |
||||||
|
window.end(); |
||||||
|
window.show(argc, argv); |
||||||
|
|
||||||
|
return Fl::run(); |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// End of "$Id: tiled_image.cxx,v 1.1.2.1 2001/11/24 18:07:58 easysw Exp $".
|
||||||
|
//
|
Loading…
Reference in new issue