Author Topic: Warning of a small bug in SaveImage  (Read 3275 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Warning of a small bug in SaveImage
« on: November 02, 2020, 01:09:44 pm »
What is the latest version of SaveImage? There is a minor bug in the version that is published in the samples section. There is a fixed channel number to open the JPG file, it must be replaced by the number assigned by the FREEFILE function. See lines 619 and 628 of the BM file. It made mistakes in my program (channel 1 was already open for something else).

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Warning of a small bug in SaveImage
« Reply #1 on: November 02, 2020, 02:52:03 pm »
I’ll be back home tomorrow, so I’ll dig into the source then to see if the glitch is in the last version available.  If so, I’ll make a quick patch and fix the issue and make it available for everyone.  This bug, for a change, sounds like it’d be a breeze to fix.  ;D
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Warning of a small bug in SaveImage
« Reply #2 on: November 03, 2020, 02:53:57 pm »
Digging into this now.  You're correct; it's an oversight in the program.  This should definitely use a FREEFILE handle here, to prevent issues.  All the other save image routines do, but this one in particular (the JPG save image code) had a hard coded file handle of 1 it relied upon, which, as you said, can cause issues.

I'm also surprised that line 685 didn't toss issues for you, as it was a CLOSE statement, without any parameters to it.  As it currently exists, it'll close every open file out there in your program, and not just the JPG file which it creates.  That's doing just a weeee bit more than intended.

A fix for these will be coming soon(tm).
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!