Page 1 of 2
Photoshop: Save as array of bytes?
Posted: Mon Jan 30, 2017 12:20 pm
by monobogdan
Hi. I'm need to save some bitmap as array of bytes. Can i do it in photoshop?
Re: Photoshop: Save as array of bytes?
Posted: Mon Jan 30, 2017 12:28 pm
by Boris
Jpg, PDF are arrays of bytes.
You need to tell us how do you want your
array of bytes to look like.
ex: all pixels row per row, without padding, in this format ?R(8bits)G(8bits)B(8bits)
Re: Photoshop: Save as array of bytes?
Posted: Mon Jan 30, 2017 12:29 pm
by monobogdan
Boris wrote:Jpg, PDF are arrays of bytes.
You need to tell us how do you want your
array of bytes to look like.
ex: all pixels row per row, without padding, in this format ?R(8bits)G(8bits)B(8bits)
Yes, export as simple C header row per row. Color format R8G8B8
Re: Photoshop: Save as array of bytes?
Posted: Mon Jan 30, 2017 1:52 pm
by Schol-R-LEA
monobogdan wrote:Boris wrote:Jpg, PDF are arrays of bytes.
You need to tell us how do you want your
array of bytes to look like.
ex: all pixels row per row, without padding, in this format ?R(8bits)G(8bits)B(8bits)
Yes, export as simple C header row per row. Color format R8G8B8
This document discusses PhotoShop format support, but it doesn't really discuss what you seem to want.
However, I can tell you definitely that GIMP will export an image as a C header (note: save the GIMP format file first, the use
Export As - the 'save' function always saves as an XCF file first, and you usually have to save first before you can export). However, the format it saves to is a lot more complex than what you are looking for, and the files it produces are enormous compared to you typical compressed image format such as PNG or JPEG - I just tried it to save a 261KB file, and the header file was over 1.6 MB. Part of this is the lack of compression - when I checked, I found that the equivalent BMP file is almost as big, at 1.1 MB - but the text format itself is not particularly suited for bitmaps in the first place (the one major text-based format, SVG - which is an XML format - is designed for defining vectors rather than bitmaps, hence the name Scalable Vector Graphics).
Re: Photoshop: Save as array of bytes?
Posted: Mon Jan 30, 2017 10:07 pm
by Love4Boobies
It sounds like you want BMP images. Parse the headers to make sure they are uncompressed 24-bit and to see if there is any palette data. The image data should be in the format you describe. Another format that is exceedingly simple to parse is PCX, which is pretty much the same, except it uses
RLE compression (i.e., repeat the next pixel a certain amount of times). Other formats are more interesting but will require more work on your part.
Re: Photoshop: Save as array of bytes?
Posted: Tue Jan 31, 2017 1:29 am
by monobogdan
Love4Boobies wrote:It sounds like you want BMP images. Parse the headers to make sure they are uncompressed 24-bit and to see if there is any palette data. The image data should be in the format you describe. Another format that is exceedingly simple to parse is PCX, which is pretty much the same, except it uses
RLE compression (i.e., repeat the next pixel a certain amount of times). Other formats are more interesting but will require more work on your part.
In VESA with some videomodes too strange color formats, 16 bit works but 24 bits not.
Re: Photoshop: Save as array of bytes?
Posted: Tue Jan 31, 2017 2:17 am
by Love4Boobies
You said something about RGB with 8 bits per channel earlier but perhaps you were replying to something else. VBE/Core does normally support 24-bit video modes but if your implementation does not, convert your image to an appropriate color depth and/or perform some quantization on the image, perhaps with dithering.
Floyd-Steinberg is particularly simple to implement.
Re: Photoshop: Save as array of bytes?
Posted: Sat Feb 04, 2017 4:19 pm
by onlyonemac
You're looking for "raw". This will give you a set of bytes representing the R, G, and B values for each pixel. You'll need to load this into RAM and then write it to the framebuffer to display it. Note that this doesn't store the size of the image, so you'll need to store or enter that separately.
(This is not the same thing as a raw file from a camera, which is another use of the term "raw" that you might come across in the context of image editing software.)
Re: Photoshop: Save as array of bytes?
Posted: Sat Feb 04, 2017 8:06 pm
by Love4Boobies
Bitmap, not raw.
Re: Photoshop: Save as array of bytes?
Posted: Sat Feb 04, 2017 9:48 pm
by Schol-R-LEA
Let's take this again from the top. @monobogdan, would you mind explaining what you are trying to accomplish, why you want a bitmap defined as a data structure in C source code, and why some other solution - say, an embedded bitmap as a blob added to the executable image, or some sort of vector definable form that you could implement a simple drawing routine for - would not work?
Re: Photoshop: Save as array of bytes?
Posted: Sun Feb 05, 2017 10:29 am
by Love4Boobies
My guess is that he wants a simple implementation so he can do something cool with his GUI (which he mentioned elsewhere on the forum). It's always fun to see a wallpaper for the first time.
Something like JPEG takes quite a while to implement.
Re: Photoshop: Save as array of bytes?
Posted: Sun Feb 05, 2017 4:28 pm
by onlyonemac
Love4Boobies wrote:Bitmap, not raw.
Requires too much parsing for a noob.
Look at it this way: the easiest possible way to get an image that you can display on the screen (think of it as a "hello world" for VGA) is by exporting as raw. Just resize your image to, say, 640x480 pixels, save it as raw, and you'll have an array of bytes ready to load into the video memory. Bitmap is the next step from there.
Re: Photoshop: Save as array of bytes?
Posted: Mon Feb 06, 2017 12:04 am
by Love4Boobies
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.
Re: Photoshop: Save as array of bytes?
Posted: Mon Feb 06, 2017 4:21 am
by dozniak
+1 to boobies, raw usually means a slightly more complicated image format.
Re: Photoshop: Save as array of bytes?
Posted: Mon Feb 06, 2017 4:34 am
by matt11235
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.