Re: Decomposing a B&W bitmap graphic (or ideally, a font bitmap)
Re: Decomposing a B&W bitmap graphic (or ideally, a font bitmap)
- Subject: Re: Decomposing a B&W bitmap graphic (or ideally, a font bitmap)
- From: Mr Tea <email@hidden>
- Date: Tue, 26 Mar 2002 15:20:35 +0000
This from email@hidden - dated 26/3/02 06:53 am:
>
I need to be able to take either a
>
black-and-white bitmapped file (tif, bmp, etc) and convert the whole thing
>
into a text file, with the pound symbol (#) representing a black pixel and a
>
period (.) representing a white pixel, and return representing the end of the
>
row of pixels.
GraphicConverter can do this for you (you can probably spot the line wraps):
tell application "GraphicConverter" to set theSize to image dimension of
window 1
set hSize to item 1 of theSize
set vSize to item 2 of theSize
set textMap to {}
set {hPixel, vPixel} to {0, 0}
repeat vSize times
repeat hSize times
tell application "GraphicConverter"
set selection of window 1 to {hPixel, vPixel, hPixel + 1, vPixel
+ 1}
set whiteOnes to count color pixels of window 1 color {65535,
65535, 65535}
if whiteOnes = 1 then
set end of textMap to "."
else
set end of textMap to "#"
end if
set hPixel to hPixel + 1
end tell
end repeat
if vPixel < vSize then
set end of textMap to return
set vPixel to vPixel + 1
set hPixel to 0
end if
end repeat
...it ain't too speedy though.
Cordially,
Mr Tea
--
Brew of the day: Ceylon
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.