QB64 Phoenix Edition
UnscramblePic.bas - Rotate picture pieces puzzle - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Prolific Programmers (https://staging.qb64phoenix.com/forumdisplay.php?fid=26)
+---- Forum: Dav (https://staging.qb64phoenix.com/forumdisplay.php?fid=34)
+---- Thread: UnscramblePic.bas - Rotate picture pieces puzzle (/showthread.php?tid=1844)

Pages: 1 2


RE: UnscramblePic.bas - Rotate picture pieces puzzle - bplus - 07-14-2023

   

Nice fix @Steffan-68


RE: UnscramblePic.bas - Rotate picture pieces puzzle - Dav - 07-14-2023

Thanks, @Steffan-68!  I updated the code with your fix.

New direct link --> unscramblepic.bas

- Dav


RE: UnscramblePic.bas - Rotate picture pieces puzzle - GareBear - 07-14-2023

With Steffan-68's fix. It works great! Thanks, Dav.


RE: UnscramblePic.bas - Rotate picture pieces puzzle - Dav - 07-15-2023

Thanks, GareBare!

I have edited all my programs found here on the forum to fix the _INFLATE error in the BASIMAGE created Subs.  

Also -- I've been trying to narrow down in my code exactly what is causes the _INFLATE error.  _INFLATE works on most of my programs without needing the 2nd parameter given.  It seems _INFLATE only needs it (m.SIZE) only in my BASIMAGE SUBs.  Other routines I use _INFLATE don't given the error (like SUBS made with the BASFILE creator).  I thought perhaps the error may happen only when using _MEM stuff (like BASIMAGE uses), but that doesn't look like it  - - the example below does what a BASIMAGE SUB does, but  m.SIZE is not required for _INFLATE to work here. Wonder why _INFLATE fails in in the BASIMAGE created Subs?

_INFLATE works correct here.  m.SIZE not needed.

Code: (Select All)
Screen _NewImage(800, 600, 32)

Dim m As _MEM: m = _MemImage(0)

'make empty space for screen data
test$ = Space$(m.SIZE): Print Len(test$)

'move screen memory into string data
_MemGet m, m.OFFSET, test$

'Compress that string data
test$ = _Deflate$(test$): Print Len(test$)

'decompress it as it was
test$ = _Inflate$(test$): Print Len(test$)

_MemFree m

- Dav


RE: UnscramblePic.bas - Rotate picture pieces puzzle - Steffan-68 - 07-15-2023

(07-15-2023, 06:07 PM)Dav Wrote: Thanks, GareBare!

I have edited all my programs found here on the forum to fix the _INFLATE error in the BASIMAGE created Subs.  

Also -- I've been trying to narrow down in my code exactly what is causes the _INFLATE error.  _INFLATE works on most of my programs without needing the 2nd parameter given.  It seems _INFLATE only needs it (m.SIZE) only in my BASIMAGE SUBs.  Other routines I use _INFLATE don't given the error (like SUBS made with the BASFILE creator).  I thought perhaps the error may happen only when using _MEM stuff (like BASIMAGE uses), but that doesn't look like it  - - the example below does what a BASIMAGE SUB does, but  m.SIZE is not required for _INFLATE to work here. Wonder why _INFLATE fails in in the BASIMAGE created Subs?

_INFLATE works correct here.  m.SIZE not needed.

- Dav

Here's the answer I got back then.


[quote pid="15751" dateline="1683562805"]
(05-07-2023, 10:29 PM)DSMan195276 Wrote:
(05-07-2023, 05:16 AM)Steffan-68 Wrote:
[quote pid="15721" dateline="1683475272"]
Has something changed in the '_MEMPUT' command?
The IDE does not report an error, but the error 'Critical Error #300 Line:833 Memory region out of range' is output in the finished compiled program.
With QB64pe V 3.6 the program runs normally, now in V 3.7 this error occurs.
We're investigating Smile It seems like an issue with the change from
zlib
to
miniz
. Your data doesn't successfully decompress with either library, but
zlib
would give you back the partially decompressed data and the correct length of it, where-as
miniz
doesn't give the length of the partially-decompressed data so
btemp$
has the wrong length.
Unfortunately
_Inflate$()
doesn't give an error if the decompression fails so you had no way to know. It really should error, but we probably can't make that change now so we're looking at a fix for
miniz
to give you the correct size. As an alternative to waiting, you code will work in v3.7.0 if you give
_Inflate$()
the size parameter, so
btemp$ = _Inflate$(btemp$, m.SIZE)
.
[/quote]
[/quote]