Photoshop: Save as array of bytes?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Viperidae
Posts: 10
Joined: Sun Sep 02, 2012 7:00 pm

Re: Photoshop: Save as array of bytes?

Post 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.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Photoshop: Save as array of bytes?

Post 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.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: Photoshop: Save as array of bytes?

Post 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
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: Photoshop: Save as array of bytes?

Post 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.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Photoshop: Save as array of bytes?

Post 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).
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Photoshop: Save as array of bytes?

Post by Schol-R-LEA »

Is the OP even still reading this thread?
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Post Reply