OSDev.org
https://forum.osdev.org/

Photoshop: Save as array of bytes?
https://forum.osdev.org/viewtopic.php?f=11&t=31322
Page 1 of 2

Author:  monobogdan [ Mon Jan 30, 2017 12:20 pm ]
Post subject:  Photoshop: Save as array of bytes?

Hi. I'm need to save some bitmap as array of bytes. Can i do it in photoshop?

Author:  Boris [ Mon Jan 30, 2017 12:28 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

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)

Author:  monobogdan [ Mon Jan 30, 2017 12:29 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

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

Author:  Schol-R-LEA [ Mon Jan 30, 2017 1:52 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

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).

Author:  Love4Boobies [ Mon Jan 30, 2017 10:07 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.

Author:  monobogdan [ Tue Jan 31, 2017 1:29 am ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.

Author:  Love4Boobies [ Tue Jan 31, 2017 2:17 am ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.

Author:  onlyonemac [ Sat Feb 04, 2017 4:19 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.)

Author:  Love4Boobies [ Sat Feb 04, 2017 8:06 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

Bitmap, not raw. :)

Author:  Schol-R-LEA [ Sat Feb 04, 2017 9:48 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

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?

Author:  Love4Boobies [ Sun Feb 05, 2017 10:29 am ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.

Author:  onlyonemac [ Sun Feb 05, 2017 4:28 pm ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.

Author:  Love4Boobies [ Mon Feb 06, 2017 12:04 am ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.

Author:  dozniak [ Mon Feb 06, 2017 4:21 am ]
Post subject:  Re: Photoshop: Save as array of bytes?

+1 to boobies, raw usually means a slightly more complicated image format.

Author:  matt11235 [ Mon Feb 06, 2017 4:34 am ]
Post subject:  Re: Photoshop: Save as array of bytes?

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.

Page 1 of 2 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/