summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2002-05-31 12:47:49 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2002-05-31 12:47:49 +0000
commit778d528093f4314bdc96f9600d0698479e8b7eb1 (patch)
tree1c37248b4119863de75c06f557f0bc0ea4d75b21 /src
parentd5541b5cd6a2584cd8f2470bdfd53b616b954462 (diff)
Add Matthias's WIN32 code to get an image from the current window; needs
testing! git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2272 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
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 $".
//