mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 16:12:13 +08:00
Add support for 2-byte XPM files.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1810 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -8,6 +8,8 @@ CHANGES IN FLTK 1.1.0b7
|
|||||||
- Fl_File_Icon::load_image() could cause segfaults
|
- Fl_File_Icon::load_image() could cause segfaults
|
||||||
(NULL data and incrementing the data pointer too
|
(NULL data and incrementing the data pointer too
|
||||||
often.)
|
often.)
|
||||||
|
- Fl_File_Icon::load_image() now handles 2-byte
|
||||||
|
per color XPM files.
|
||||||
- Some Win32 drivers would draw into wrong buffers
|
- Some Win32 drivers would draw into wrong buffers
|
||||||
after OpenGL mode change.
|
after OpenGL mode change.
|
||||||
- Message handling and Resources for MacOS port.
|
- Message handling and Resources for MacOS port.
|
||||||
|
|||||||
+22
-20
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_File_Icon2.cxx,v 1.1.2.5 2001/12/05 00:06:41 easysw Exp $"
|
// "$Id: Fl_File_Icon2.cxx,v 1.1.2.6 2001/12/05 00:19:26 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Fl_File_Icon system icon routines.
|
// Fl_File_Icon system icon routines.
|
||||||
//
|
//
|
||||||
@@ -410,7 +410,7 @@ Fl_File_Icon::load_image(const char *ifile) // I - File to read from
|
|||||||
*const*ptr; // Pointer into data array
|
*const*ptr; // Pointer into data array
|
||||||
int ncolors, // Number of colors
|
int ncolors, // Number of colors
|
||||||
chars_per_color; // Characters per color
|
chars_per_color; // Characters per color
|
||||||
Fl_Color colors[256]; // Colors
|
Fl_Color *colors; // Colors
|
||||||
int red, green, blue; // Red, green, and blue values
|
int red, green, blue; // Red, green, and blue values
|
||||||
int x, y; // X & Y in image
|
int x, y; // X & Y in image
|
||||||
int startx; // Starting X coord
|
int startx; // Starting X coord
|
||||||
@@ -419,15 +419,11 @@ Fl_File_Icon::load_image(const char *ifile) // I - File to read from
|
|||||||
// Get the pixmap data...
|
// Get the pixmap data...
|
||||||
ptr = img->data();
|
ptr = img->data();
|
||||||
sscanf(*ptr, "%*d%*d%d%d", &ncolors, &chars_per_color);
|
sscanf(*ptr, "%*d%*d%d%d", &ncolors, &chars_per_color);
|
||||||
if (chars_per_color > 1) {
|
|
||||||
Fl::warning("Fl_Icon_File::load(): Unable to load 2-byte XPM file \"%s\"!",
|
colors = new Fl_Color[1 << (chars_per_color * 8)];
|
||||||
ifile);
|
|
||||||
img->release();
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the colormap...
|
// Read the colormap...
|
||||||
memset(colors, 0, sizeof(colors));
|
memset(colors, 0, sizeof(Fl_Color) << (chars_per_color * 8));
|
||||||
bg = ' ';
|
bg = ' ';
|
||||||
|
|
||||||
ptr ++;
|
ptr ++;
|
||||||
@@ -448,6 +444,8 @@ Fl_File_Icon::load_image(const char *ifile) // I - File to read from
|
|||||||
lineptr = *ptr;
|
lineptr = *ptr;
|
||||||
ch = *lineptr++;
|
ch = *lineptr++;
|
||||||
|
|
||||||
|
if (chars_per_color > 1) ch = (ch << 8) | *lineptr++;
|
||||||
|
|
||||||
// Get the color value...
|
// Get the color value...
|
||||||
if ((lineptr = strstr(lineptr, "c ")) == NULL) {
|
if ((lineptr = strstr(lineptr, "c ")) == NULL) {
|
||||||
// No color; make this black...
|
// No color; make this black...
|
||||||
@@ -516,17 +514,18 @@ Fl_File_Icon::load_image(const char *ifile) // I - File to read from
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the image data...
|
// Read the image data...
|
||||||
for (y = 0; y < img->h(); y ++, ptr ++)
|
for (y = 0; y < img->h(); y ++, ptr ++) {
|
||||||
{
|
|
||||||
lineptr = *ptr;
|
lineptr = *ptr;
|
||||||
startx = 0;
|
startx = 0;
|
||||||
ch = bg;
|
ch = bg;
|
||||||
|
|
||||||
for (x = 0; x < img->w(); x ++, lineptr ++)
|
for (x = 0; x < img->w(); x ++) {
|
||||||
if (*lineptr != ch)
|
newch = *lineptr++;
|
||||||
{
|
|
||||||
if (ch != bg)
|
if (chars_per_color > 1) newch = (newch << 8) | *lineptr++;
|
||||||
{
|
|
||||||
|
if (newch != ch) {
|
||||||
|
if (ch != bg) {
|
||||||
add_color(colors[ch]);
|
add_color(colors[ch]);
|
||||||
add(POLYGON);
|
add(POLYGON);
|
||||||
add_vertex(startx * 9000 / img->w() + 1000, 9500 - y * 9000 / img->h());
|
add_vertex(startx * 9000 / img->w() + 1000, 9500 - y * 9000 / img->h());
|
||||||
@@ -536,12 +535,12 @@ Fl_File_Icon::load_image(const char *ifile) // I - File to read from
|
|||||||
add(END);
|
add(END);
|
||||||
}
|
}
|
||||||
|
|
||||||
ch = *lineptr;
|
ch = newch;
|
||||||
startx = x;
|
startx = x;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ch != bg)
|
if (ch != bg) {
|
||||||
{
|
|
||||||
add_color(colors[ch]);
|
add_color(colors[ch]);
|
||||||
add(POLYGON);
|
add(POLYGON);
|
||||||
add_vertex(startx * 9000 / img->w() + 1000, 9500 - y * 9000 / img->h());
|
add_vertex(startx * 9000 / img->w() + 1000, 9500 - y * 9000 / img->h());
|
||||||
@@ -551,6 +550,9 @@ Fl_File_Icon::load_image(const char *ifile) // I - File to read from
|
|||||||
add(END);
|
add(END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Free the colormap...
|
||||||
|
delete[] colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->release();
|
img->release();
|
||||||
@@ -923,5 +925,5 @@ get_kde_val(char *str,
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_File_Icon2.cxx,v 1.1.2.5 2001/12/05 00:06:41 easysw Exp $".
|
// End of "$Id: Fl_File_Icon2.cxx,v 1.1.2.6 2001/12/05 00:19:26 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user