It is currently Sun Jun 30, 2024 8:58 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Image to bit map file
PostPosted: Sun Jun 21, 2020 10:11 am  (#1) 
Offline
GimpChat Member

Joined: Jun 21, 2020
Posts: 5
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


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Image to bit map file
PostPosted: Sun Jun 21, 2020 11:52 am  (#2) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
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?

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Image to bit map file
PostPosted: Sun Jun 21, 2020 11:58 am  (#3) 
Offline
GimpChat Member

Joined: Jun 21, 2020
Posts: 5
Sorry.
Here is the png not bin. I grabbed the wrong link.Image


Top
 Post subject: Re: Image to bit map file
PostPosted: Sun Jun 21, 2020 12:15 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: May 10, 2013
Posts: 1389
Location: FInland
Image/Mode/Indexed/Black & White 1-bit?


Attachments:
Convert-image-to-1bit.png
Convert-image-to-1bit.png [ 44.12 KiB | Viewed 2545 times ]
Finch-1-bit.png
Finch-1-bit.png [ 1.01 KiB | Viewed 2545 times ]
Top
 Post subject: Re: Image to bit map file
PostPosted: Sun Jun 21, 2020 12:48 pm  (#5) 
Offline
GimpChat Member

Joined: Jun 21, 2020
Posts: 5
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.


Top
 Post subject: Re: Image to bit map file
PostPosted: Sun Jun 21, 2020 2:03 pm  (#6) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2435
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

_________________
Image


Top
 Post subject: Re: Image to bit map file
PostPosted: Sun Jun 21, 2020 2:25 pm  (#7) 
Offline
GimpChat Member

Joined: Jun 21, 2020
Posts: 5
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.


Top
 Post subject: Re: Image to bit map file
PostPosted: Mon Jun 22, 2020 3:08 am  (#8) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2435
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


Attachments:
64-color.zip [388 Bytes]
Downloaded 82 times

_________________
Image
Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Image quality and file size hacks

9

No new posts Retexture an image with another image as "Image Pattern" Plug-in

4

No new posts Show image on web browser to fill 100% width AND image map

2

No new posts "New"file replacing "open" file?

2

No new posts GIH FILE

2



* Login  



Powered by phpBB3 © phpBB Group