QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: bartok on July 15, 2021, 04:45:57 am
-
I think it is a simple issue... but I haven't found nothing.
I don't have to load images into QB64, I have to transform images created with QB64 in images as PNG, BMP, JPG. How to do that?
-
From what you are saying, and the way that I understand what you are saying, is that you need to transform or convert images into other graphics formats? If that is the case, then I am not sure if QB64 has a method of doing that, but you best method would be to use a graphics editor like Photoshop or Gimp to convert the images.
I hope this helps.
J
ps: If I have mis-understood your meaning then I apologize.
-
From what you are saying, and the way that I understand what you are saying, is that you need to transform or convert images into other graphics formats? If that is the case, then I am not sure if QB64 has a method of doing that, but you best method would be to use a graphics editor like Photoshop or Gimp to convert the images.
I hope this helps.
J
ps: If I have mis-understood your meaning then I apologize.
no no. I have images like "image&" created in QB64 with _NEWIMAGE and graphics statements, like LINE, POINT and so on, and I want to create the corresponding output files, in PNG or BMP or JPG format, for example.
-
@bartok
If your created images are actually shown on the computer screen you can do this a number of ways...
A non-QB64 way in Windows 10 is to take a screenshot (---> .png file) and then use eg MS Paint to convert the .png to other formats.
A very fast QB64 way (using _MEM memory blocks) is an adaption of @SMcNeill method in Steve's Save Image2.3
https://www.qb64.org/forum/index.php?topic=2701.0 (https://www.qb64.org/forum/index.php?topic=2701.0)
to save a .BMP etc. file.
If your images are stored in an array, you can use BSAVE (not recommended use PUT # instead) - refer
QB64 IDE > Help > Keyword Index > BSAVE (example 2 BSAVEing a bitmap)
Hope the above helps.
-
Bartok,
Ah. My mistake. I had obviously misunderstood your request. Just ignore my suggestion and go with Richard's.
J
-
I think it is a simple issue... but I haven't found nothing.
I don't have to load images into QB64, I have to transform images created with QB64 in images as PNG, BMP, JPG. How to do that?
Steve McNeill has code for that
https://www.qb64.org/forum/index.php?topic=1651.0
I used it and works pretty well, Ken Sierra used it to save pictures drawn in his Paint like program if I recall :)
Update: maybe it was Dav who set him up with something... but Dav's not here (as much), he's got gig's again. :)
@SMcNeill might have a more current SaveImage version floating around in another thread with a bug fix.
From Steve's forum (currently closed to new members):
https://qb64.freeforums.net/thread/55/save-image-library
-
This subroutine works perfectly:
http://www.qb64.org/wiki/SAVEIMAGE
but I have to say that I don't have understood anything at all how it works, also reading the explanation.
Starting from:
b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later)
It a mystery. Someone has an idea?
-
http://www.petesqbsite.com/sections/tutorials/zines/qbcm/12-bmps.html (http://www.petesqbsite.com/sections/tutorials/zines/qbcm/12-bmps.html)
good reference
-
Steve McNeill has code for that
https://www.qb64.org/forum/index.php?topic=1651.0
@SMcNeill might have a more current SaveImage version floating around in another thread with a bug fixes.
As far as I know, v2.3b is probably going to be the last, and final, version of SaveImage. (It’s the version linked to above.)
As it exists, it saves images as PNG, BMP, JPG, and GIF formats. I really don’t have the time, interest, or need to decode some other image format, so I doubt I’ll expand it to add additional formats anytime soon. (I’d once considered adding the webp format, but then I learned it’s not universally adopted, and I really don’t have a need for anything else.)
V2.3b fixes all the known bugs and reported issues that I know of, and unless something in QB64 (or the c-compiler we use) itself changes over time, or somebody reports an issue that needs fixing, it’ll probably sit unchanging for the foreseeable future.
-
Transform an image& into a file, I see that it is not so easy as to load a file into an image&. Probabily it would be a good idea to create a specific QB64 command to do that. I have finally taken the subroutine (http://www.qb64.org/wiki/SAVEIMAGE) even if I absolutely didn't understand anything of it, but it works fine. Never mind the code od SMCNeil that it count even 3 files... and that is even more complicated! Maybe I will try to undestand when I finish the program.
-
As far as I know, v2.3b is probably going to be the last, and final, version of SaveImage. (It’s the version linked to above.)
Hi @SMcNeill, just note you're a step further already 2.3c:
https://www.qb64.org/forum/index.php?topic=2701.0
-
This subroutine works perfectly:
http://www.qb64.org/wiki/SAVEIMAGE
but I have to say that I don't have understood anything at all how it works, also reading the explanation.
Starting from:
b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later)
It a mystery. Someone has an idea?
BMP files are actually rather simple to create and decode. The way they work is to basically store your image in 2 parts — the header and then the data.
The header is a leading batch of information that basically stores your height, width, color size, and such, and it looks like:
TYPE BMPEntry ' Description Bytes QB64 Function
ID AS STRING * 2 ' File ID("BM" text or 19778 AS Integer) 2 CVI("BM")
Size AS LONG ' Total Size of the file 4 LOF
Res1 AS INTEGER ' Reserved 1 always 0 2
Res2 AS INTEGER ' Reserved 2 always 0 2
Offset AS LONG ' Start offset of image pixel data 4 (add one for GET)
END TYPE ' Total 14
TYPE BMPHeader 'BMP header also used in Icon and Cursor files(.ICO and .CUR)
Hsize AS LONG ' Info header size (always 40) 4
PWidth AS LONG ' Image width 4 _WIDTH(handle&)
PDepth AS LONG ' Image height (doubled in icons) 4 _HEIGHT(handle&)
Planes AS INTEGER ' Number of planes (normally 1) 2
BPP AS INTEGER ' Bits per pixel(palette 1, 4, 8, 24) 2 _PIXELSIZE(handle&)
Compression AS LONG ' Compression type(normally 0) 4
ImageBytes AS LONG ' (Width + padder) * Height 4
Xres AS LONG ' Width in PELS per metre(normally 0) 4
Yres AS LONG ' Depth in PELS per metre(normally 0) 4
NumColors AS LONG ' Number of Colors(normally 0) 4 2 ^ BPP
SigColors AS LONG ' Significant Colors(normally 0) 4
END TYPE ' Total Header bytes = 40
After the header, unless you’re storing a color palette, or using RLE compression, comes the data, which is basically the color value of each pixel which encompasses an image.
-
Hi @SMcNeill, just note you're a step further already 2.3c:
https://www.qb64.org/forum/index.php?topic=2701.0
The Librarian ought to update that some day.
-
Hi @SMcNeill, just note you're a step further already 2.3c:
https://www.qb64.org/forum/index.php?topic=2701.0
Aye, but this one was such an unique use-case correction, it’s more or less unnecessary except for Petr’s specific application. It doesn’t really hurt to have the change for others, but in most use-cases, it’ll never affect anything one way or the other. Personally, 2.3b is the version I tend to keep and use myself. It corrected the CRC issues which sometimes rendered PNG images unreadable in certain apps, so I’d definitely suggest everyone *at least* use that version, or above, and not any of the older ones.
-
The Librarian ought to update that some day.
Done! Yeah I noticed this morning that Richard had already linked to the last updated version. I thought there was one after 2.3b.
@SMcNeill are you still archiving at
https://qb64.freeforums.net
or just github now?
-
Done! Yeah I noticed this morning that Richard had already linked to the last updated version. I thought there was one after 2.3b.
@SMcNeill are you still archiving at
https://qb64.freeforums.net
or just github now?
Both, when I get around to actually updating anything. It’s been ~6 months, or so, since I last did anything seriously. I’m still in “R&R Mode”.