88
99#include " config.h"
1010#include < math.h>
11- #include < stdint.h>
1211#include " ui/utils.h"
13- #include " ui/rgb.h"
1412#include " platform/fltk/display.h"
1513
1614GraphicsWidget *graphics;
@@ -130,7 +128,6 @@ void drawImage(void *data, int x, int y, int w, uchar *out) {
130128 int scanLine = w * 3 ;
131129 int offs = y * w * 4 ;
132130 float op = opacity / 100 .0f ;
133- fprintf (stderr, " op=%f\n " , op);
134131
135132 for (int sx = 0 ; sx < scanLine; sx += 3 , offs += 4 ) {
136133 uint8_t a = image[offs + 3 ];
@@ -149,6 +146,7 @@ void drawImage(void *data, int x, int y, int w, uchar *out) {
149146 dG = dG + ((g - dG) * a / 255 );
150147 dB = dB + ((b - dB) * a / 255 );
151148 }
149+ out[sx + 3 ] = a;
152150 out[sx + 2 ] = dR;
153151 out[sx + 1 ] = dG;
154152 out[sx + 0 ] = dB;
@@ -203,23 +201,31 @@ void Canvas::fillRect(int left, int top, int width, int height, Fl_Color color)
203201
204202void Canvas::getImageData (uint8_t *image, const MARect *srcRect, int bytesPerLine) {
205203 fl_begin_offscreen (_offscreen);
206- int x = srcRect->left ;
207- int y = srcRect->top ;
208- int w = srcRect->width ;
209- int h = srcRect->height ;
204+ unsigned x = srcRect->left ;
205+ unsigned y = srcRect->top ;
206+ unsigned w = srcRect->width ;
207+ unsigned h = srcRect->height ;
210208 fl_read_image (image, x, y, w, h, 1 );
211209 fl_end_offscreen ();
212210
213211 if (srcRect->width == 1 && srcRect->height == 1 ) {
214212 // compatibility with PSET/POINT
215- uchar r = image[0 ];
216- uchar g = image[1 ];
217213 uchar b = image[2 ];
218- uchar a = image[3 ];
219- image[0 ] = b ;
220- image[1 ] = g ;
214+ uchar g = image[1 ];
215+ uchar r = image[0 ];
216+ image[3 ] = 255 ;
221217 image[2 ] = r;
222- image[3 ] = a;
218+ image[1 ] = g;
219+ image[0 ] = b;
220+ } else {
221+ // set alpha to 255
222+ for (unsigned y = 0 ; y < h; y++) {
223+ unsigned yoffs = (4 * y * w);
224+ for (unsigned x = 0 ; x < w; x++) {
225+ int offs = yoffs + (x * 4 );
226+ image[offs + 3 ] = 255 ;
227+ }
228+ }
223229 }
224230}
225231
0 commit comments