Skip to content

Commit

Permalink
Now look for 8 bits of alpha when the developer has requested
Browse files Browse the repository at this point in the history
FL_RGB8 (STR #541)

The last line in an Fl_Help_View widget was not aligned properly
(STR #536)

The "search" symbol looked like a Q (STR #536)

Changed Fl_Help_View::get_color() to use a lookup table to avoid
serious Borland C++ 5.5 compiler bugs (STR #533)

Fixed Watcom compiler warnings with FL/Fl_Widget.H (STR #540)

The image class copy() methods did not always make a separate
copy of the image data (STR #539)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3844 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Sep 24, 2004
1 parent 44a7ad2 commit 18ad096
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 103 deletions.
14 changes: 14 additions & 0 deletions CHANGES
Expand Up @@ -3,6 +3,20 @@ CHANGES IN FLTK 1.1.5rc3
- Documentation updates (STR #505, STR #513)
- Updated PNG library source to 1.2.7.
- Updated ZLIB library source to 1.2.1.
- Fixed VC++ project file problems (STR #476, STR #478,
STR #520, STR #527, STR #537)
- Now look for 8 bits of alpha when the developer has
requested FL_RGB8 (STR #541)
- The last line in an Fl_Help_View widget was not
aligned properly (STR #536)
- The "search" symbol looked like a Q (STR #536)
- Changed Fl_Help_View::get_color() to use a lookup
table to avoid serious Borland C++ 5.5 compiler bugs
(STR #533)
- Fixed Watcom compiler warnings with FL/Fl_Widget.H
(STR #540)
- The image class copy() methods did not always make a
separate copy of the image data (STR #539)
- Fixed an edge case in fl_old_shortcut() that could
cause it to read beyond then end of the shortcut
string (used for XForms named shortcuts)
Expand Down
12 changes: 6 additions & 6 deletions FL/Fl_Widget.H
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget.H,v 1.6.2.4.2.24 2004/07/27 16:02:18 easysw Exp $"
// "$Id: Fl_Widget.H,v 1.6.2.4.2.25 2004/09/24 16:00:08 easysw Exp $"
//
// Widget header file for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -81,10 +81,10 @@ protected:

Fl_Widget(int,int,int,int,const char* =0);

void x(int v) {x_ = v;}
void y(int v) {y_ = v;}
void w(int v) {w_ = v;}
void h(int v) {h_ = v;}
void x(int v) {x_ = (short)v;}
void y(int v) {y_ = (short)v;}
void w(int v) {w_ = (short)v;}
void h(int v) {h_ = (short)v;}

int flags() const {return flags_;}
void set_flag(int c) {flags_ |= c;}
Expand Down Expand Up @@ -217,5 +217,5 @@ public:
#endif

//
// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.24 2004/07/27 16:02:18 easysw Exp $".
// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.25 2004/09/24 16:00:08 easysw Exp $".
//
3 changes: 1 addition & 2 deletions documentation/drawing.html
Expand Up @@ -858,8 +858,7 @@ <H4>void draw(int x, int y, int w, int h, int ox = 0, int oy = 0);</H4>
<H4>void draw(int x, int y)</H4>

<P>Draws the image with the upper-left corner at <TT>x,y</TT>.
This is the same as doing
<TT>draw(x,y,img->w(),img->h(),0,0)</TT>.
This is the same as doing <TT>draw(x,y,img->w(),img->h(),0,0)</TT>.

</BODY>
</HTML>
25 changes: 17 additions & 8 deletions src/Fl_Bitmap.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.26 2004/08/31 22:00:47 matthiaswm Exp $"
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.27 2004/09/24 16:00:10 easysw Exp $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -432,14 +432,23 @@ void Fl_Bitmap::label(Fl_Menu_Item* m) {
}

Fl_Image *Fl_Bitmap::copy(int W, int H) {
Fl_Bitmap *new_image; // New RGB image
uchar *new_array; // New array for image data

// Optimize the simple copy where the width and height are the same...
if (W == w() && H == h()) return new Fl_Bitmap(array, w(), h());
if (W == w() && H == h()) {
new_array = new uchar [H * ((W + 7) / 8)];
memcpy(new_array, array, H * ((W + 7) / 8));

new_image = new Fl_Bitmap(new_array, W, H);
new_image->alloc_array = 1;

return new_image;
}
if (W <= 0 || H <= 0) return 0;

// OK, need to resize the image data; allocate memory and
Fl_Bitmap *new_image; // New RGB image
uchar *new_array, // New array for image data
*new_ptr, // Pointer into new array
uchar *new_ptr, // Pointer into new array
new_bit, // Bit for new array
old_bit; // Bit for old array
const uchar *old_ptr; // Pointer into old array
Expand All @@ -457,11 +466,11 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
ystep = h() / H;

// Allocate memory for the new image...
new_array = new uchar [H * (W + 7) / 8];
new_array = new uchar [H * ((W + 7) / 8)];
new_image = new Fl_Bitmap(new_array, W, H);
new_image->alloc_array = 1;

memset(new_array, 0, H * (W + 7) / 8);
memset(new_array, 0, H * ((W + 7) / 8));

// Scale the image using a nearest-neighbor algorithm...
for (dy = H, sy = 0, yerr = H, new_ptr = new_array; dy > 0; dy --) {
Expand Down Expand Up @@ -501,5 +510,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {


//
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.26 2004/08/31 22:00:47 matthiaswm Exp $".
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.27 2004/09/24 16:00:10 easysw Exp $".
//
10 changes: 5 additions & 5 deletions src/Fl_Gl_Choice.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.21 2004/09/09 21:34:46 matthiaswm Exp $"
// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.22 2004/09/24 16:00:10 easysw Exp $"
//
// OpenGL visual selection code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -66,7 +66,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
list[n++] = (m & FL_RGB8) ? 8 : 1;
if (m & FL_ALPHA) {
list[n++] = AGL_ALPHA_SIZE;
list[n++] = 1;
list[n++] = (m & FL_RGB8) ? 8 : 1;
}
if (m & FL_ACCUM) {
list[n++] = AGL_ACCUM_GREEN_SIZE;
Expand Down Expand Up @@ -116,7 +116,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
list[n++] = (m & FL_RGB8) ? 8 : 1;
if (m & FL_ALPHA) {
list[n++] = AGL_ALPHA_SIZE;
list[n++] = 1;
list[n++] = (m & FL_RGB8) ? 8 : 1;
}
if (m & FL_ACCUM) {
list[n++] = AGL_ACCUM_GREEN_SIZE;
Expand Down Expand Up @@ -166,7 +166,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
list[n++] = (m & FL_RGB8) ? 8 : 1;
if (m & FL_ALPHA) {
list[n++] = GLX_ALPHA_SIZE;
list[n++] = 1;
list[n++] = (m & FL_RGB8) ? 8 : 1;
}
if (m & FL_ACCUM) {
list[n++] = GLX_ACCUM_GREEN_SIZE;
Expand Down Expand Up @@ -439,5 +439,5 @@ void fl_delete_gl_context(GLContext context) {


//
// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.21 2004/09/09 21:34:46 matthiaswm Exp $".
// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.22 2004/09/24 16:00:10 easysw Exp $".
//
106 changes: 48 additions & 58 deletions src/Fl_Help_View.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Help_View.cxx,v 1.1.2.53 2004/07/27 16:02:20 easysw Exp $"
// "$Id: Fl_Help_View.cxx,v 1.1.2.54 2004/09/24 16:00:10 easysw Exp $"
//
// Fl_Help_View widget routines.
//
Expand Down Expand Up @@ -1508,7 +1508,7 @@ Fl_Help_View::format()
}
}

if (s > buf && !pre && !head)
if (s > buf && !head)
{
*s = '\0';
ww = (int)fl_width(buf);
Expand Down Expand Up @@ -1538,16 +1538,15 @@ Fl_Help_View::format()
add_link(linkdest, xx, yy - fsize, ww, fsize);

xx += ww;
if ((fsize + 2) > hh)
hh = fsize + 2;

needspace = 0;
}

do_align(block, line, xx, newalign, links);

block->end = ptr;
size_ = yy + hh;
}


if (ntargets_ > 1)
qsort(targets_, ntargets_, sizeof(Fl_Help_Target),
(compare_func_t)compare_targets);
Expand Down Expand Up @@ -2125,66 +2124,57 @@ Fl_Color // O - Color value
Fl_Help_View::get_color(const char *n, // I - Color name
Fl_Color c) // I - Default color value
{
int i; // Looping var
int rgb, r, g, b; // RGB values
static const struct { // Color name table
const char *name;
int r, g, b;
} colors[] = {
{ "black", 0x00, 0x00, 0x00 },
{ "red", 0xff, 0x00, 0x00 },
{ "green", 0x00, 0x80, 0x00 },
{ "yellow", 0xff, 0xff, 0x00 },
{ "blue", 0x00, 0x00, 0xff },
{ "magenta", 0xff, 0x00, 0xff },
{ "fuchsia", 0xff, 0x00, 0xff },
{ "cyan", 0x00, 0xff, 0xff },
{ "aqua", 0x00, 0xff, 0xff },
{ "white", 0xff, 0xff, 0xff },
{ "gray", 0x80, 0x80, 0x80 },
{ "grey", 0x80, 0x80, 0x80 },
{ "lime", 0x00, 0xff, 0x00 },
{ "maroon", 0x80, 0x00, 0x00 },
{ "navy", 0x00, 0x00, 0x80 },
{ "olive", 0x80, 0x80, 0x00 },
{ "purple", 0x80, 0x00, 0x80 },
{ "silver", 0xc0, 0xc0, 0xc0 },
{ "teal", 0x00, 0x80, 0x80 }
};


if (!n || !n[0])
return (c);
if (!n || !n[0]) return c;

if (n[0] == '#')
{
if (n[0] == '#') {
// Do hex color lookup
rgb = strtol(n + 1, NULL, 16);

r = rgb >> 16;
g = (rgb >> 8) & 255;
b = rgb & 255;

if (strlen(n) > 4) {
r = rgb >> 16;
g = (rgb >> 8) & 255;
b = rgb & 255;
} else {
r = (rgb >> 8) * 17;
g = ((rgb >> 4) & 15) * 17;
b = (rgb & 15) * 17;
}
return (fl_rgb_color((uchar)r, (uchar)g, (uchar)b));
} else {
for (i = 0; i < (int)(sizeof(colors) / sizeof(colors[0])); i ++)
if (!strcasecmp(n, colors[i].name)) {
return fl_rgb_color(colors[i].r, colors[i].g, colors[i].b);
}
return c;
}
else if (strcasecmp(n, "black") == 0)
return (FL_BLACK);
else if (strcasecmp(n, "red") == 0)
return (FL_RED);
#ifdef __BORLANDC__ // Workaround for compiler bug...
else if (strcasecmp(n, "green") == 0) {
r = 0;
g = 0x80;
b = 0;
return (fl_rgb_color(r, g, b));
}
#else
else if (strcasecmp(n, "green") == 0)
return (fl_rgb_color(0, 0x80, 0));
#endif // __BORLANDC__
else if (strcasecmp(n, "yellow") == 0)
return (FL_YELLOW);
else if (strcasecmp(n, "blue") == 0)
return (FL_BLUE);
else if (strcasecmp(n, "magenta") == 0 || strcasecmp(n, "fuchsia") == 0)
return (FL_MAGENTA);
else if (strcasecmp(n, "cyan") == 0 || strcasecmp(n, "aqua") == 0)
return (FL_CYAN);
else if (strcasecmp(n, "white") == 0)
return (FL_WHITE);
else if (strcasecmp(n, "gray") == 0 || strcasecmp(n, "grey") == 0)
return (fl_rgb_color(0x80, 0x80, 0x80));
else if (strcasecmp(n, "lime") == 0)
return (FL_GREEN);
else if (strcasecmp(n, "maroon") == 0)
return (fl_rgb_color(0x80, 0, 0));
else if (strcasecmp(n, "navy") == 0)
return (fl_rgb_color(0, 0, 0x80));
else if (strcasecmp(n, "olive") == 0)
return (fl_rgb_color(0x80, 0x80, 0));
else if (strcasecmp(n, "purple") == 0)
return (fl_rgb_color(0x80, 0, 0x80));
else if (strcasecmp(n, "silver") == 0)
return (fl_rgb_color(0xc0, 0xc0, 0xc0));
else if (strcasecmp(n, "teal") == 0)
return (fl_rgb_color(0, 0x80, 0x80));
else
return (c);
}


Expand Down Expand Up @@ -2811,5 +2801,5 @@ hscrollbar_callback(Fl_Widget *s, void *)


//
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.53 2004/07/27 16:02:20 easysw Exp $".
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.54 2004/09/24 16:00:10 easysw Exp $".
//
22 changes: 16 additions & 6 deletions src/Fl_Image.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.37 2004/08/31 22:00:47 matthiaswm Exp $"
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.38 2004/09/24 16:00:10 easysw Exp $"
//
// Image drawing code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -141,18 +141,28 @@ void Fl_RGB_Image::uncache() {
}

Fl_Image *Fl_RGB_Image::copy(int W, int H) {
Fl_RGB_Image *new_image; // New RGB image
uchar *new_array; // New array for image data

// Optimize the simple copy where the width and height are the same,
// or when we are copying an empty image...
if ((W == w() && H == h()) ||
!w() || !h() || !d() || !array) {
return new Fl_RGB_Image(array, w(), h(), d(), ld());
if (array) {
// Make a copy of the image data and return a new Fl_RGB_Image...
new_array = new uchar[w() * h() * d()];
memcpy(new_array, array, w() * h() * d());

new_image = new Fl_RGB_Image(new_array, w(), h(), d(), ld());
new_image->alloc_array = 1;

return new_image;
} else return new Fl_RGB_Image(array, w(), h(), d(), ld());
}
if (W <= 0 || H <= 0) return 0;

// OK, need to resize the image data; allocate memory and
Fl_RGB_Image *new_image; // New RGB image
uchar *new_array, // New array for image data
*new_ptr; // Pointer into new array
uchar *new_ptr; // Pointer into new array
const uchar *old_ptr; // Pointer into old array
int c, // Channel number
sy, // Source coordinate
Expand Down Expand Up @@ -418,5 +428,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {


//
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.37 2004/08/31 22:00:47 matthiaswm Exp $".
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.38 2004/09/24 16:00:10 easysw Exp $".
//
14 changes: 10 additions & 4 deletions src/Fl_Pixmap.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.32 2004/08/31 22:00:47 matthiaswm Exp $"
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.33 2004/09/24 16:00:10 easysw Exp $"
//
// Pixmap drawing code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -233,12 +233,18 @@ void Fl_Pixmap::copy_data() {
}

Fl_Image *Fl_Pixmap::copy(int W, int H) {
Fl_Pixmap *new_image; // New pixmap

// Optimize the simple copy where the width and height are the same...
if (W == w() && H == h()) return new Fl_Pixmap(data());
if (W == w() && H == h()) {
// Make an exact copy of the image and return it...
new_image = new Fl_Pixmap(data());
new_image->copy_data();
return new_image;
}
if (W <= 0 || H <= 0) return 0;

// OK, need to resize the image data; allocate memory and
Fl_Pixmap *new_image; // New pixmap
char **new_data, // New array for image data
**new_row, // Pointer to row in image data
*new_ptr, // Pointer into new array
Expand Down Expand Up @@ -473,5 +479,5 @@ void Fl_Pixmap::desaturate() {
}

//
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.32 2004/08/31 22:00:47 matthiaswm Exp $".
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.33 2004/09/24 16:00:10 easysw Exp $".
//

0 comments on commit 18ad096

Please sign in to comment.