OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 1:50 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Picture Support (BMP,JPG,..)
PostPosted: Sat Aug 27, 2005 11:00 pm 
Offline

Joined: Fri Oct 29, 2004 11:00 pm
Posts: 22
Hello,

now my floppy driver works well and I can execute simple programs in my OS ... now I would like to create a GUI for my OS ... Window's, Buttons,... works fine ... but I'd like to show Pictures in my OS ... now i try to load a 24-Bit BMP file in the memory and show it on the Background ... i can read the header informations of the file ( Width,Height,...) but I couldn't finde the correct color out ...

Can somebody help me ... maybe sombody can show me an simple example for a BMP or JPGE picture ... JPGE will be much better because it doesn't need so much memory on the floppy disk ...

I hope somebody can help me ... thanks


Top
 Profile  
 
 Post subject: Re: Picture Support (BMP,JPG,..)
PostPosted: Sat Aug 27, 2005 11:00 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2004 12:00 am
Posts: 195
Well, probably libjpeg doesn't need that much runtime support if compiled correctly ...

_________________
*post*


Top
 Profile  
 
 Post subject: Re: Picture Support (BMP,JPG,..)
PostPosted: Sat Aug 27, 2005 11:00 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 21, 2004 11:00 pm
Posts: 349
Location: Munich, Germany
Hello,
the big advantage of a raw bmp file compared to jpeg is its great simplicity, especially with 24bit colors as in this case a color-table isn't needed. The whole file-format thus only consists of two simple header structures followed directly by the raw 24bit pixeldata.

BitmapFileHeader
BitmapInfoHeader

You can also assume that the image-data in the bitmap isn't compressed but only consists of RGB triplets which each represent a pixel. For some reason the image is stored bottom-up, that means that the first pixel is in the lower left corner and that the last pixel is in the upper right corner.

5 -> 6 -> 7 -> 8
1 -> 2 -> 3 -> 4

Apart from that each scan-line is aligned to a 32bit boundary which means that a padding is added if [pixels_per_line*24bits)%32bits != 0]. As you know the scanline lenght from the headers it's no big deal to calculate where the next line start. Assuming that you have set your display adapter to a 24bit mode all you have to do in order to display the image is to copy the data bottom-up and with respect the the padding to the linear frame-buffer.

Code:
xres = infoheader.biWidth;
yres = biWidth.biHeight;

p_rgb_data = bitmap_location + fileheader.bfOffBits;
p_framebuffer = 0x12345678;

for(i=yres; i>0; i--)
{
    for(j=0; j<xres; j++)
    {
        p_framebuffer[i*xres*3 + j*3 + 0] = &p_rgd_data;  // red
        p_rgd_data++;
       
        p_framebuffer[i*xres*3 + j*3 + 1] = &p_rgd_data;  // green
        p_rgd_data++;

        p_framebuffer[i*xres*3 + j*3 + 2] = &p_rgd_data;  // blue
        p_rgd_data++;
    }
   
    ; jump over the padding at the end of the scanline
    if(p_rgd_data%4 != 0)
    {
        p_rgd_data += (4 - p_rgd_data%4)
    }
}


This is just some pseudo-code and as I haven't tested it you shouldn't be too surpised if it contains some bugs ;)

regards,
gaf


Top
 Profile  
 
 Post subject: Re: Picture Support (BMP,JPG,..)
PostPosted: Sun Aug 28, 2005 11:00 pm 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 1223
Location: Sweden
For more information about BMP:
http://www.g615.co.uk/riftor/bmpstructure.txt

_________________
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub


Top
 Profile  
 
 Post subject: Re: Picture Support (BMP,JPG,..)
PostPosted: Thu Sep 08, 2005 11:00 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
if your using mode 13h(or its equivalent in pmode or whatever) or anything less than 24 bit color than you will need to convert device indepent bitmaps into device dependent pixel data but if your in 24bit or 32bit mode than it should be simple

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: Picture Support (BMP,JPG,..)
PostPosted: Sun Sep 25, 2005 11:00 pm 
Offline

Joined: Sun Sep 25, 2005 11:00 pm
Posts: 1
hmm.. i am showing pictures at the moment, too. And i think, you have to go into the vesa mode, too show more than 256 colours..


Top
 Profile  
 
 Post subject: Re: Picture Support (BMP,JPG,..)
PostPosted: Sun Sep 25, 2005 11:00 pm 
Offline
Member
Member

Joined: Sat Jun 25, 2005 11:00 pm
Posts: 25
check this out

http://www.wotsit.org/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 198 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