Hi!
Inspired by a post I've seen on reddit I created this program to convert any file to a bmp image file.
Here is a small game (in a zipped file) viewed as bmp image:
And here is the fromtoimage.exe in a bmp file:
The encoding is simple, each pixel in the image encodes 3 bytes (red, green, blue) from the input file. The first 3 pixels store the file size. The program is a command line one, to see the usage just execute it without any parameters.
Thanks!
FromToImage - Program to convert any file to bmp image
-
- Enthusiast
- Posts: 115
- Joined: Sat Sep 21, 2019 4:24 pm
FromToImage - Program to convert any file to bmp image
You can check my games at:
https://ricardo-sdl.itch.io/
https://ricardo-sdl.itch.io/
-
- Enthusiast
- Posts: 494
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: FromToImage - Program to convert any file to bmp image
Hi,
Thanks it is a nice idea to store this as image file...
Greetings Michael
Thanks it is a nice idea to store this as image file...
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
Re: FromToImage - Program to convert any file to bmp image
Nice job! I recommend saving to PNG instead of BMP, it should be a smaller file size and still preserve every pixel value.
-
- Enthusiast
- Posts: 115
- Joined: Sat Sep 21, 2019 4:24 pm
Re: FromToImage - Program to convert any file to bmp image
Thanks @mpz and @kenmo!
I didn't think about png's
It might actually create images smaller than the original file.
I didn't think about png's
It might actually create images smaller than the original file.
You can check my games at:
https://ricardo-sdl.itch.io/
https://ricardo-sdl.itch.io/
Re: FromToImage - Program to convert any file to bmp image
Thank you - that's very simple and very cool!
I changed the image format to PNG and it reduces the image size for fromtoimage.exe from 74 KB (BMP) to 38 KB (PNG).
I changed the image format to PNG and it reduces the image size for fromtoimage.exe from 74 KB (BMP) to 38 KB (PNG).
-
- Enthusiast
- Posts: 115
- Joined: Sat Sep 21, 2019 4:24 pm
Re: FromToImage - Program to convert any file to bmp image
Nice! The thing with png's is that we can use less pixels also to store the input file, because of transparency we can store 4 bytes per pixel.
You can check my games at:
https://ricardo-sdl.itch.io/
https://ricardo-sdl.itch.io/
Re: FromToImage - Program to convert any file to bmp image
Hi Ricardo,
I'm trying to do exactly that - using 32-bit images, replacing RGB with RGBA, changing all references from 3 bytes to 4 bytes, etc., but so far I haven't been able to make it work. I think I'm creating the image correctly, but I can't decode it back to the original file. Can you tell me if 32-bit images store pixels as RGBA or ARGB or ???Nice! The thing with png's is that we can use less pixels also to store the input file, because of transparency we can store 4 bytes per pixel.
-
- Enthusiast
- Posts: 115
- Joined: Sat Sep 21, 2019 4:24 pm
Re: FromToImage - Program to convert any file to bmp image
I created a branch where the images are saved and read as png. It also uses the alpha channel to store 4 bytes per pixel.
The fromtoimage.exe now looks like this:
Not as striking as before because of the lots of transparent pixels
This is the branch with the updated code:
https://github.com/ricardosdl/FromToIma ... /saveAsPNG
Not much was changed, but I had to use "DrawingMode(#PB_2DDrawing_AllChannels)" after the calls to StartDrawing, so when we read a pixel or plot one the alpha channel was actually used.
The fromtoimage.exe now looks like this:
Not as striking as before because of the lots of transparent pixels
This is the branch with the updated code:
https://github.com/ricardosdl/FromToIma ... /saveAsPNG
Not much was changed, but I had to use "DrawingMode(#PB_2DDrawing_AllChannels)" after the calls to StartDrawing, so when we read a pixel or plot one the alpha channel was actually used.
You can check my games at:
https://ricardo-sdl.itch.io/
https://ricardo-sdl.itch.io/
Re: FromToImage - Program to convert any file to bmp image
Hi Ricardo,
Thanks for the updated version.
The interesting thing (to me) is that a version I made that just used the PNG format instead of BMP, with no use of the alpha bytes to store data, produces a PNG image that is almost exactly the same size as your 4-byte version (37.2 KB vs. 37.1 KB) from the same input file.
In any case, this has been a very interesting learning exercise - thanks again!
Regards,
Eric
Thanks for the updated version.
The interesting thing (to me) is that a version I made that just used the PNG format instead of BMP, with no use of the alpha bytes to store data, produces a PNG image that is almost exactly the same size as your 4-byte version (37.2 KB vs. 37.1 KB) from the same input file.
In any case, this has been a very interesting learning exercise - thanks again!
Regards,
Eric