Page 2 of 2

Re: Photoshop: Save as array of bytes?

Posted: Tue Feb 07, 2017 12:21 am
by Viperidae
As other people suggested, it seems you just want an uncompressed array of colors? You could easily write a script to extract the RGB data from an image and save it as a raw bitmap. Here's some incomplete Python code I hacked together using PIL to do this very thing a while ago if it helps https://hastebin.com/vucimudapa.py

Note: This isn't really too salable. I would suggest trying to actually just parse a BMP file or add some information to what ever raw format you want to use that specifies the dimensions of the image.

Re: Photoshop: Save as array of bytes?

Posted: Fri Feb 10, 2017 1:10 pm
by onlyonemac
Love4Boobies wrote:No, that's what that data structure is called and it can be used for many things, not just images (e.g., this is often what people on this forum use for their first allocators). It's a contiguous map of bits, where each bit (or group of bits) represents an equal part of the whole, in succession.

To my knowledge, Photoshop is the only program which uses this weird "raw" name in the way that you have, which normally suggests something else to anyone familiar with raw data coming from CCD's. However, it's really uncommon and requires elaboration (i.e., "the Photoshop kind") so I suggest avoiding this meaning altogether.

EDIT: See this section on Wikipedia.
dozniak wrote:+1 to boobies, raw usually means a slightly more complicated image format.
matt11235 wrote:
dozniak wrote:+1 to boobies, raw usually means a slightly more complicated image format.
RAW is usually the data straight from the sensor of the camera, it requires a lot of processing before you can get something to look at.
Exporting an image that has already been processed as a RAW doesn't really make sense, much like going from a 32kbps mp3 to a 1000kbps FLAC.
As I already said, I am aware of the existence of "raw" files in digital photography. However both Photoshop and GIMP use the term "raw" to refer to raw pixel data (a.k.a. "bitmap" in the "array of bits" sense rather than the ".bmp file" sense) rather than raw camera files.

Re: Photoshop: Save as array of bytes?

Posted: Fri Feb 10, 2017 1:41 pm
by matt11235
onlyonemac wrote:As I already said, I am aware of the existence of "raw" files in digital photography. However both Photoshop and GIMP use the term "raw" to refer to raw pixel data (a.k.a. "bitmap" in the "array of bits" sense rather than the ".bmp file" sense) rather than raw camera files.
Whoops yes, you're correct. In Photoshop the camera files are referred to as "Adobe Camera Raw" wile the raw pixel data is just "Photoshop Raw". Thanks for clearing that up

Re: Photoshop: Save as array of bytes?

Posted: Fri Feb 10, 2017 6:11 pm
by Kazinsal
Photoshop RAW exports 24-bit, unless you have non-opaque pixels, then it can export 32-bit. If you need 32-bit raw bitmaps you could export a 32-bit uncompressed TGA, and rip out the headers and footer.

Or leave in the headers and footer, since TGA is an incredibly simple format that was designed to basically encapsulate packed pixel data that could be blitted to a framebuffer.

Re: Photoshop: Save as array of bytes?

Posted: Sat Feb 11, 2017 6:18 am
by onlyonemac
Kazinsal wrote:Photoshop RAW exports 24-bit, unless you have non-opaque pixels, then it can export 32-bit. If you need 32-bit raw bitmaps you could export a 32-bit uncompressed TGA, and rip out the headers and footer.

Or leave in the headers and footer, since TGA is an incredibly simple format that was designed to basically encapsulate packed pixel data that could be blitted to a framebuffer.
Again this depends if we're trying to do VGA "hello world" or if we're trying to actually parse an image file format. In the former case, trying to parse headers just adds extra room for bugs and makes it harder to figure out where something's going wrong (i.e. "is the problem with copying the data into the framebuffer, or are we actually copying the wrong data in the first place?").

Also, I don't know about Photoshop, but GIMP is able to export as either "standard" (interlaced - with each successive byte giving the red, green, and blue values in turn) format or planar (where all the red values are given first, then all the green values, then all the blue values) format. The latter could be useful for some VGA modes which use a planar framebuffer. There doesn't seem to be an option to save the alpha channel even if the image contains transparent areas (although one could always save it separately by extracting the alpha channel as a greyscale image and combining the resulting raw image files, which would take a bit of work but should be fairly simple for anyone competent in C and/or with experience in processing raw image data).

Re: Photoshop: Save as array of bytes?

Posted: Sat Feb 11, 2017 10:19 am
by Schol-R-LEA
Is the OP even still reading this thread?