@Petr I was digging around in the demo you sent me, and trying to reproduce the glitch you'd asked about. As far as I can tell, the issue is down inside the SaveImage.BM file, in the SaveJPG routine itself -- and at a spot that had me completely baffled for the longest time...
In the BM, around line 617 (give or take, as I've did some modification which might shift lines up or down a few spots), there's a small routine which takes our existing screen and converts it over to a temporary screen for SaveJPG to work with, as it's a rather limited routine which expects to save the whole screen to file. What we're doing is just taking the portion of the screen which we want to save, making it a temp screen, and then saving that whole temp screen, rather than picking and choosing start and end points in the routine for a partial screen...
You'll see where we create the tempimage, and then you'll see where we put the part of the old image we want onto the new image...
And there's where the glitch is!
Something in that _PUTIMAGE isn't doing what it should be. We're putting a 256 color image onto a 32-bit screen -- without tossing any sort of error message, which I find rather unbelievable! -- and the only colors that are being transferred properly are the solid white. Everything else is coming across as a low-to-zero alpha color value, and basically being _PUT as invisible colors. (I think. I wouldn't swear at WTH _PUTIMAGE is doing here, but I'm certain it's doing something weird as heck and not working properly in this case.)
To prove it, test the following:
Remark out the _PUTIMAGE (0,0)..., image&,tempimage&, ... line, and replace it with the following:
r
= _RED(POINT(x
+ startx
, y
+ starty
), image&
)
Here, we're manually reading each point of the 256 color image and converting it to a 32-bit color value, before PSETing it back where it belongs on the 32-bit screen. And, as far as I can tell, going this route works, whereas the _PUTIMAGE only puts the white value to the image and nothing else.
Make the simple change in your own program, to test it out, and if this is the correction needed, I'll make the change to the SaveImage library and eliminate the glitch for good for us, in the future. ;)