Photoshop: Save as array of bytes?
-
- Member
- Posts: 71
- Joined: Wed Jan 25, 2017 3:37 pm
Photoshop: Save as array of bytes?
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?
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)
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)
-
- Member
- Posts: 71
- Joined: Wed Jan 25, 2017 3:37 pm
Re: Photoshop: Save as array of bytes?
Yes, export as simple C header row per row. Color format R8G8B8Boris 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)
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: Photoshop: Save as array of bytes?
This document discusses PhotoShop format support, but it doesn't really discuss what you seem to want.monobogdan wrote:Yes, export as simple C header row per row. Color format R8G8B8Boris 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)
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).
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.
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.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
-
- Member
- Posts: 71
- Joined: Wed Jan 25, 2017 3:37 pm
Re: Photoshop: Save as array of bytes?
In VESA with some videomodes too strange color formats, 16 bit works but 24 bits not.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.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
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.)
(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.)
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Photoshop: Save as array of bytes?
Bitmap, not raw.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
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?
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.
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.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Photoshop: Save as array of bytes?
Requires too much parsing for a noob.Love4Boobies wrote:Bitmap, not raw.
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.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
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.
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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Photoshop: Save as array of bytes?
+1 to boobies, raw usually means a slightly more complicated image format.
Learn to read.
Re: Photoshop: Save as array of bytes?
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.dozniak wrote:+1 to boobies, raw usually means a slightly more complicated image format.
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.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
Compiler Development Forum