Where's my image data in memory?
Posted: Mon Jun 29, 2009 1:20 am
I'm still very much a PB beginner but getting a bit better with practice.
I want to simplify the 24 bit RGB data in a colour bitmap into a 'custom' 8-bit format (imagine it's a grayscale, although that's not exactly what I'll be doing). Assume the original image is a .jpg. I then want to do a bit of threshold detection math on the custom data. Finally, I want to show a (rudimentary) thumbnail image using the custom data,
My solution:
Using the .jpg converter plug-in, load the image.
Save the loaded image as a .bmp
Open the .bmp as a 'binary' file (do we have those in PB?)
Read the first part of the file, ie the .bmp header- get file length, image height/width etc
DIM array.l() as a store for the 8-bit data
Read sequentially the R+G+B data from the .bmp file
Do the 24 to 8 bit math conversion and store result in array()
Do the 'analysis' stuff on array() & save to disk
Read through array(), then use a palette to return some 'pseudoRGB' values
Display the pseudoRGB using PLOT
I've tried the PLOT routine by simply drawing on a window. I don't have a particular speed problem with that. I expect it could display faster using StartDrawing(ImageOutput)/ImageGadget/LoadImage or better still, drawn onto a WindowedScreen. That's not a priority.
This seems very kludgy. Can I access the actual image data in memory using PEEK? What are the other better ways?
Thanks.
Al
I want to simplify the 24 bit RGB data in a colour bitmap into a 'custom' 8-bit format (imagine it's a grayscale, although that's not exactly what I'll be doing). Assume the original image is a .jpg. I then want to do a bit of threshold detection math on the custom data. Finally, I want to show a (rudimentary) thumbnail image using the custom data,
My solution:
Using the .jpg converter plug-in, load the image.
Save the loaded image as a .bmp
Open the .bmp as a 'binary' file (do we have those in PB?)
Read the first part of the file, ie the .bmp header- get file length, image height/width etc
DIM array.l() as a store for the 8-bit data
Read sequentially the R+G+B data from the .bmp file
Do the 24 to 8 bit math conversion and store result in array()
Do the 'analysis' stuff on array() & save to disk
Read through array(), then use a palette to return some 'pseudoRGB' values
Display the pseudoRGB using PLOT
I've tried the PLOT routine by simply drawing on a window. I don't have a particular speed problem with that. I expect it could display faster using StartDrawing(ImageOutput)/ImageGadget/LoadImage or better still, drawn onto a WindowedScreen. That's not a priority.
This seems very kludgy. Can I access the actual image data in memory using PEEK? What are the other better ways?
Thanks.
Al