CONST SaveTextAs256Color
= 0 'or -1 if you want to save screen 0 text screens in 256 colors 'Note, you can also make the variable DIM SHARED, and then change its value as needed for your work.
' Just change its value before you make the call to SaveBMP or SaveFullBMP.
'**************************
' Code beyond this point can go into a nice SaveBMPLibrary.BM
'**************************
SUB SaveFullBMP
(filename$
)
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&
l&
= (_WIDTH * _HEIGHT) * 2 'The screen is width * height in pixels. (80X25) = 2000 X 2 bytes each = 4000 total bytes to hold a page of screen 0 text and color
o = m.OFFSET
_PUTIMAGE , tempscreen&
, Screen0to256&
, (0, 0)-(w&
, h&
) TextScreenToImage256 = Screen0to256&
l&
= (_WIDTH * _HEIGHT) * 2 'The screen is width * height in pixels. (80X25) = 2000 X 2 bytes each = 4000 total bytes to hold a page of screen 0 text and color
o = m.OFFSET
fgc
= b
MOD 16: bgc
= b \
16 COLOR _RGB32(_RED(fgc
, image&
), _GREEN(fgc
, image&
), _BLUE(fgc
, image&
)), _RGB32(_RED(bgc
, image&
), _GREEN(bgc
, image&
), _BLUE(bgc
, image&
)) _PUTIMAGE , tempscreen&
, Screen0to32&
, (0, 0)-(w&
, h&
) TextScreenToImage32 = Screen0to32&