summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fl_read_image_win32.cxx37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/fl_read_image_win32.cxx b/src/fl_read_image_win32.cxx
index d7e35b58b..6c9617369 100644
--- a/src/fl_read_image_win32.cxx
+++ b/src/fl_read_image_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_read_image_win32.cxx,v 1.1.2.1 2002/05/30 15:09:03 easysw Exp $"
+// "$Id: fl_read_image_win32.cxx,v 1.1.2.2 2002/05/31 12:47:49 easysw Exp $"
//
// WIN32 image reading routines for the Fast Light Tool Kit (FLTK).
//
@@ -29,15 +29,42 @@
uchar * // O - Pixel buffer or NULL if failed
fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
- int x, // I - Left position
- int y, // I - Top position
+ int X, // I - Left position
+ int Y, // I - Top position
int w, // I - Width of area to read
int h, // I - Height of area to read
int alpha) { // I - Alpha value for image (0 for none)
- return 0;
+ int x, y; // Looping vars
+ int d; // Depth of image
+ uchar *ptr; // Pointer in image data
+
+
+ // Allocate the image data array as needed...
+ d = alpha ? 4 : 3;
+
+ if (!p) p = new uchar[w * h * d];
+
+ // Initialize the default colors/alpha in the whole image...
+ memset(p, alpha, w * h * d);
+
+ // Grab all of the pixels in the image, one at a time...
+ // MRS: there has to be a better way than this!
+ for (y = 0, ptr = p; y < h; y ++) {
+ for (x = 0; x < w; x ++, ptr += d) {
+ COLORREF c = GetPixel(fl_gc, X + x, Y + y);
+
+ ptr[0] = c;
+ c >>= 8;
+ ptr[1] = c;
+ c >>= 8;
+ ptr[2] = c;
+ }
+ }
+
+ return p;
}
//
-// End of "$Id: fl_read_image_win32.cxx,v 1.1.2.1 2002/05/30 15:09:03 easysw Exp $".
+// End of "$Id: fl_read_image_win32.cxx,v 1.1.2.2 2002/05/31 12:47:49 easysw Exp $".
//