OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:36 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Photoshop: Save as array of bytes?
PostPosted: Mon Jan 30, 2017 12:20 pm 
Offline
Member
Member

Joined: Wed Jan 25, 2017 3:37 pm
Posts: 71
Hi. I'm need to save some bitmap as array of bytes. Can i do it in photoshop?


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Mon Jan 30, 2017 12:28 pm 
Offline
Member
Member

Joined: Sat Nov 07, 2015 3:12 pm
Posts: 145
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)


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Mon Jan 30, 2017 12:29 pm 
Offline
Member
Member

Joined: Wed Jan 25, 2017 3:37 pm
Posts: 71
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


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Mon Jan 30, 2017 1:52 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
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).

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


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Mon Jan 30, 2017 10:07 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Tue Jan 31, 2017 1:29 am 
Offline
Member
Member

Joined: Wed Jan 25, 2017 3:37 pm
Posts: 71
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.


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Tue Jan 31, 2017 2:17 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Sat Feb 04, 2017 4:19 pm 
Offline
Member
Member

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

_________________
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


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Sat Feb 04, 2017 8:06 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Bitmap, not raw. :)

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Sat Feb 04, 2017 9:48 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
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.


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Sun Feb 05, 2017 10:29 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Sun Feb 05, 2017 4:28 pm 
Offline
Member
Member

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

_________________
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


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Mon Feb 06, 2017 12:04 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Mon Feb 06, 2017 4:21 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
+1 to boobies, raw usually means a slightly more complicated image format.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Photoshop: Save as array of bytes?
PostPosted: Mon Feb 06, 2017 4:34 am 
Offline
Member
Member
User avatar

Joined: Tue Aug 02, 2016 1:52 pm
Posts: 286
Location: East Riding of Yorkshire, UK
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.

_________________
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group