Author Topic: Save Image 2.3d  (Read 13035 times)

0 Members and 1 Guest are viewing this topic.

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Save Image 2.3c
« Reply #30 on: March 22, 2021, 06:08:35 pm »
Hi @SMcNeill

Oh sounds like you have your hands full at the moment with some stressful situations, take care of yourself and I hope your sister gets better. Alzheimers is really tough to deal with.
No rush on save image whenever it  suits your situation.




Right now, I’m stuck down at my mom’s, watching over her.  (She has early onset Alzheimers and has to be monitored 24/7.). Usually my sister takes her about half the time, but the doctors just diagnosed her with breast cancer.  She’s got to go talk to the surgeons on the 30th of this month, so I’ll be stuck here for at least another month.  If things settle down in a few weeks, I’ll try and set aside time to make SaveImage Option _Explicit compatible.
Brian ...

Offline mohai

  • Newbie
  • Posts: 20
    • View Profile
Re: Save Image 2.3c
« Reply #31 on: September 02, 2021, 05:06:12 pm »
Hello all,

First of all, I wish Steve and all his relatives are well.

The library is great. It is full of interesting and useful features.

I am doing a small project and want to export some pictures to PNG and BMP format.
Your library is great for that but, my program is taking longer and longer to compile now.
I want to make a "light" version so, deleting all the functions I will not use.

I hope you do not mind whether I modify it.


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Save Image 2.3c
« Reply #32 on: September 02, 2021, 05:16:16 pm »
Feel free.  That’s why I shared it, for others to use and enjoy.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline mohai

  • Newbie
  • Posts: 20
    • View Profile
Re: Save Image 2.3c
« Reply #33 on: September 06, 2021, 02:09:07 pm »
Feel free.  That’s why I shared it, for others to use and enjoy.  ;)

Thanks  lot.
I made a "Save Image Light" from it with the routines to save PNGs and BMPs only.
It works great.
By the way, I did some minors modifications here an there (REM to redundant lines and correct a small bug)

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Save Image 2.3c
« Reply #34 on: September 12, 2021, 12:08:07 am »
What a super-handy-dandy program!

I've used it to:
1) downsize some of my chess sets so they load faster. MSpaint didn't preserve the alpha
    background.
2) automate the conversion of thousands of picture files for optimal display on my phone
    (320x480), along with maptriangle for rotation.

I'll probably find other uses for it, like taking screenshots.

Thanks, Steve!

It works better if you plug it in.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Save Image 2.3c
« Reply #35 on: November 21, 2021, 08:11:21 pm »
@SMcNeill  Just FYI the recent adjustment\fix to functions has created an issue with your BM file.
More specifically QB64 has an issue with this line now:

    IF PNGExport <> 0 THEN

within the PNGExport function
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Save Image 2.3c
« Reply #36 on: November 22, 2021, 07:03:45 pm »
Also, How much work would it be to allow exported images to be larger than 32767 pixels on an axis?
Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Save Image 2.3c
« Reply #37 on: November 22, 2021, 09:02:47 pm »
Also, How much work would it be to allow exported images to be larger than 32767 pixels on an axis?

What type of images?  PNG, BMP, JPG, or GIF?  Each has their own specification, and I don't remember what all the various limits are off the top of my head.

Many of the older image types are stuck with 32-bit specifications.  32,767 x 32,767 pixels x 4 bytes per pixel for 32-bit images gives a 4GB file size -- the absolute most you can push into an UNSIGNED LONG.  Easiest solution here would be to just do a pure memdump of your oversized image yourself, using DEFLATE and INFLATE on it, and save it as a custom data format.  It's the way I'd go with it, if I was writing a program to *ONLY* run in 64-bit OSes.
« Last Edit: November 22, 2021, 09:15:06 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Save Image 2.3c
« Reply #38 on: November 22, 2021, 09:39:29 pm »
The Tile List I'm working with has 1064 tiles at 32pixels a tile which come to 34048x32.
the current layout is 8 tiles wide by 133 rows.
though that includes Map tiles and Item tiles so I may just split it up into 2 tile sheets.

I like keeping it 1 tile high and just really long to simplify the selection process. Just worrying about the X location of a tile instead of both X and Y.

Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Save Image 2.3c
« Reply #39 on: November 22, 2021, 10:54:45 pm »
I don't think it's going to work for you like that, @Cobalt

Here's a simple little routine which does a screen dump to a file for us, and then restores that screen back for us...   Take a look at it at work.

Code: QB64: [Select]
  1. Screen _NewImage(1024, 720, 32)
  2. Dim Shared foo, q$, q2$
  3. foo = _NewImage(100000, 32, 32)
  4.  
  5. _Dest foo
  6. For i = o To 100000
  7.     Line (i, 0)-Step(0, 31), &HFF000000 + Rnd * &HFFFFFF
  8.  
  9. ImageDump32 foo, "fooImage.dmp"
  10. Print "Image created and saved to disk..."
  11. Print "Now loading..."
  12.  
  13. NewImage = ImageRestore32("fooImage.dmp")
  14.  
  15.  
  16. For i& = 0 To 100000 Step 100
  17.     Locate 5, 1: Print i&; "/"; 100000
  18.     _PutImage (0, 100)-(1024, 132), NewImage, 0, (i&, 0)-Step(1024, 32)
  19.     _Limit 60
  20.     _Display
  21.  
  22.  
  23. Sub ImageDump32 (image, file$) 'only for 32-bit screens
  24.     Dim m As _MEM: m = _MemImage(image)
  25.     w&& = _Width(image): h&& = _Height(image)
  26.     t$ = Space$(m.SIZE): _MemGet m, m.OFFSET, t$
  27.     t2$ = _Deflate$(t$)
  28.     f = FreeFile
  29.     Open file$ For Output As #f: Close f 'erase any old file with this name
  30.     Open file$ For Binary As #f
  31.     Put #f, , w&&
  32.     Put #f, , h&&
  33.     Put #f, , t2$
  34.     Close f
  35.     _MemFree m
  36.  
  37. Function ImageRestore32 (file$) 'only for 32-bit screens
  38.     f = FreeFile
  39.     Open file$ For Binary As #f
  40.     Get #f, , w&&
  41.     Get #f, , h&&
  42.     t2$ = Space$(LOF(f) - 16)
  43.     Get #f, , t2$
  44.     Close f
  45.     t$ = _Inflate$(t2$)
  46.     tempImage = _NewImage(w&&, h&&, 32)
  47.     Dim m As _MEM: m = _MemImage(tempImage)
  48.     ImageRestore32 = tempImage
  49.     _MemPut m, m.OFFSET, t$
  50.     _MemFree m
  51.  

At first, I was curious if *I* was the one who made a mistake in my code somewhere, but being the flawless and perfect programmer that I am, I quickly ruled that option out.  ;D

Taking all the screen dump and files size/load stuff out, we end up with this really simple little program here:

Code: QB64: [Select]
  1. Screen _NewImage(1024, 720, 32)
  2. foo = _NewImage(100000, 32, 32)
  3.  
  4. _Dest foo
  5. For i = o To 100000
  6.     Line (i, 0)-Step(0, 31), &HFF000000 + Rnd * &HFFFFFF
  7.  
  8.  
  9. For i& = 0 To 100000 Step 10
  10.     Locate 5, 1: Print i&; "/"; 100000
  11.     _PutImage (0, 100)-(1024, 132), foo, 0, (i&, 0)-Step(1024, 32)
  12.     _Limit 60
  13.     _Display

Let it run and watch what happens when it gets up around that 33k pixel mark...  i& keeps incrementing, but the screen stops updating -- it's ran out of image to copy from!

If I had to take a guess, without looking at the source, I'd say that limit is QB64's max image limit just as much as anything else.  Unless somebody finds something wrong with the simple code above, I think what you're looking for is beyond the limits of QB64's images.  You're going to have to go at least 2 layers deep, or else write 2 different image files, to make things work properly, I'd imagine.

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Marked as best answer by SMcNeill on November 30, 2021, 11:37:11 am

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Save Image 2.3d
« Reply #40 on: November 30, 2021, 04:28:40 pm »
Updated to version 2.3d.

Only one little change here -- a fix to the issue which pops up in the latest version of QB64 due to the changes in FUNCTION and recursive calls.  If you're using a version of QB64 before 2.0, then you don't need to worry about this download.  For all users of QB64 v2.0 and up, you'll need this package instead of the old one.  (Note, older users can use SaveImage 2.3d just fine, so there's no reason NOT to download and use this one.  It's just not *required* for you to upgrade above 2.3c, unless you're using QB64v2.0 or newer.)

* SaveImage v2.3d.7z (Filesize: 29.95 KB, Downloads: 157)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!