Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_SaveImage less then 32BPP
#4
My solution?

Code: (Select All)
Screen _NewImage(1500, 1500, 11)
Line (1000, 100)-(1200, 200), 1, BF
Dim m As _MEM
m = _MemImage(0)
s$ = Space$(m.SIZE - 1)
_MemGet m, m.OFFSET, s$

s$ = _Deflate$(s$)
Print Len(s$) 'the size compressed

Sleep 'so you can see the current white box
Cls
_MemPut m, m.OFFSET, _Inflate$(s$) 'and here you can restore the image
Sleep

Now note that this doesn't do an image file dump, so if you NEED this for other programs to be able to load like an image, it's not suitable for your use case.  

BUT!!!

If you just need to save the screen to reference it in a different QB64 program, or to restore later, then *THIS* is the simple trick to use.

1) Make your image.  (at 15000 x 15000, it kept crashing to me as my PC was casting to multiple devices at the time and somehow that simply wouldn't play nice as a screen resolution, so for this demo it's a simple 1500 x 1500 size.)
2) Take a _MemImage of it
3) Set a string to that size
4) Compress that string with _Deflate$.   Now you have a tiny footprint to save to disk or keep in memory for later use.
5) Use _WriteFile$ to write that string to the disk.

... do whatever you want now.  When you need to make use of it:

1) _ReadFile$ that file back into a string
2) _Deflate that string
3) _MemPut it back to your screen

You can do this in fractions of seconds and have very small files to boot!   Unless you just HAVE to have the file in an image format to use in other programs or whatnot, this is the method I'd use for such things -- just save and load the image memory directly.
Reply


Messages In This Thread
_SaveImage less then 32BPP - by mdijkens - 02-17-2026, 12:47 PM
RE: _SaveImage less then 32BPP - by Petr - 02-17-2026, 04:09 PM
RE: _SaveImage less then 32BPP - by mdijkens - 02-17-2026, 04:36 PM
RE: _SaveImage less then 32BPP - by SMcNeill - 02-17-2026, 04:50 PM
RE: _SaveImage less then 32BPP - by Petr - 02-17-2026, 04:52 PM
RE: _SaveImage less then 32BPP - by ahenry3068 - 02-17-2026, 05:03 PM
RE: _SaveImage less then 32BPP - by a740g - 02-17-2026, 09:45 PM
RE: _SaveImage less then 32BPP - by SMcNeill - 02-17-2026, 04:46 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)