_SCREENHIDE 'Hide our QB64 screen, so we don't grab a capture of it SCREEN QB64Screen
'set our screen _SCREENSHOW 'Show our QB64 screen, so we can see what we're doing _SCREENMOVE 0, 0 'move it to the top left of our desktop
SaveBMP
"UpsideDown.bmp", 0, 0, 0, _WIDTH, _HEIGHT 'Save it to the drive
SUB SaveBMP
(filename$
, image&
, x1%
, y1%
, x2%
, y2%
) 'Super special STEVE-Approved BMP Export routine for use with any QB64 graphic mode.
tempimage& = TextScreenToImage256&(image&)
tempimage& = TextScreenToImage32&(image&)
SaveBMP filename$, tempimage&, x1% * FW, y1% * FH, x2% * FW, y2% * FH
IF x2%
= _WIDTH(imagehandle%
) THEN x2%
= _WIDTH(imagehandle%
) - 1 'troubleshoot in case user does a common mistake for 0-width instead of 0 - (width-1) for fullscreen IF y2%
= _HEIGHT(imagehandle%
) THEN y2%
= _HEIGHT(imagehandle%
) - 1 'troubleshoot in case user does a common mistake for 0-width instead of 0 - (width-1) for fullscreen
BMP.PWidth = (x2% - x1%) + 1
BMP.PDepth = (y2% - y1%) + 1
BMP.ID = "BM"
BMP.Blank = 0
BMP.Hsize = 40
BMP.Planes = 1
BMP.Compression = 0
BMP.Xres = 0
BMP.Yres = 0
BMP.SigColors = 0
OffsetBITS& = 54 + 1024 'add palette in 256 color modes
BMP.BPP = 8
ImageSize&
= (BMP.PWidth
+ LEN(ZeroPAD$
)) * BMP.PDepth
BMP.ImageBytes = ImageSize&
BMP.NumColors = 256
BMP.Size = ImageSize& + OffsetBITS&
BMP.Offset = OffsetBITS&
OffsetBITS& = 54 'no palette in 24/32 bit
BMP.BPP = 24
ImageSize&
= (BMP.PWidth
+ LEN(ZeroPAD$
)) * BMP.PDepth
BMP.ImageBytes = ImageSize&
BMP.NumColors = 0
BMP.Size = ImageSize& * 3 + OffsetBITS&
BMP.Offset = OffsetBITS&
o = n.OFFSET + 54
IF BMP.BPP
= 8 THEN 'Store the Palette for 256 color mode FOR c&
= 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0)) o = o + 4
y = y2% + 1
x = x2% - x1% + 1
y = y - 1
_MEMGET m
, m.OFFSET
+ (w&
* y
+ x1%
), temp
o = o + x
o = o + zp&
y = y2% + 1
y = y - 1: x = x1% - 1
x = x + 1
_MEMGET m
, m.OFFSET
+ (w&
* y
+ x
) * 4, temp
o = o + 3
o = o + zp&