Switch to full style
Ask all general Gimp related questions here
Post a reply

Image to bit map file

Sun Jun 21, 2020 10:11 am

GIMP Version: 2.10.20
Operating System: Windows
OS Version: 10
GIMP Experience: New User
URL or Image link: https://eater.net/downloads/finch.bin

List any relevant plug-ins or scripts:
from PIL import Image

image = Image.open("finch.png")
pixels = image.load()

out_file = open("finch.bin", "wb")

for y in range(256):
for x in range(128):
try:
out_file.write(chr(pixels[x, y]))
except IndexError:
out_file.write(chr(0))


List any ERROR messages you received:
Traceback (most recent call last):
File "<input>", line 1, in <module>
ImportError: No module named PIL

Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'Image' is not defined

Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'image' is not defined




I have this script that should make a bit map file of an image, but it was made for Photoshop.

How do I do the same thing but with GIMP?


If any of you are familliar with an EEPROM...
I want to make a bit map that the pixels can be read horizontally (lowers address values A0-A6).
The lines would be vertical and would be addressed by the higher values (A7-A13)

I would really want a suitable 200x150 image to be converted to above format.
The image I linked is an example image but its 100x75.
I have a video link if you see the guy do the stuff in Adobe to know what exactly I am talking about

Re: Image to bit map file

Sun Jun 21, 2020 11:52 am

Why would you post a bin file? Why not just screenshot the bin when you have it open on your end, and then convert it to jpg or png?

Re: Image to bit map file

Sun Jun 21, 2020 11:58 am

Sorry.
Here is the png not bin. I grabbed the wrong link.Image

Re: Image to bit map file

Sun Jun 21, 2020 12:15 pm

Image/Mode/Indexed/Black & White 1-bit?

Re: Image to bit map file

Sun Jun 21, 2020 12:48 pm

Hm.

How do i get the raw pixel data? And write it to a new file? (BIN)
I think thats what I am trying to ask.

I want to load the picture into an EEPROM...no file information should be saved.

Re: Image to bit map file

Sun Jun 21, 2020 2:03 pm

The png file needs to be in indexed mode and maybe only 64 colours Use Image -> Mode -> Indexed and set the number of colours

Image

This using linux. I have no idea how PIL is installed in Windows

However, with file and script in a folder, edit the script to suit file names / image size. Run the script and it outputs the .bin file.

Image

best of luck

Re: Image to bit map file

Sun Jun 21, 2020 2:25 pm

Thanks. I figured out that I just need to install Python to run the script.

For some reason I thought Photoshop came with the ability to do what Ben Eater did. Kinda stupid.

Re: Image to bit map file

Mon Jun 22, 2020 3:08 am

In case OP ever comes back.

Looking on the eater.net/ site the conversion to Indexed mode uses a color palette "64-color.act" Not a format that Gimp uses. Not difficult to manually re-write to .gpl format. (attached) Unzip then 64-color.gpl goes in C:\Users\"yourname"\AppData\Roaming\GIMP\2.10\palettes

Conversion Image -> Mode -> Indexed Set the palette. Set one of the dither modes. Export as a png. Example:

Image
Post a reply