Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Bitmaps!!!!!!!!!!! Posted by cof123 on 26 Dec 2004 at 9:13 AM
I have started programming a few years ago and i would like to know how to decode a bitmap image and then display it on the screen. all i have managed to do is convert the bitmap into numbers having the first two chratcers being BM and the next character representing the size of the image in bytes. I have tried to search on the internet but all i found was codes in C which i do not understand. Please can anyone send me an e-mail with some sample codes on : cof123@gmail.com
Report
Re: Bitmaps!!!!!!!!!!! Posted by netgert on 26 Dec 2004 at 12:44 PM
: I have started programming a few years ago and i would like to know how to decode a bitmap image and then display it on the screen. all i have managed to do is convert the bitmap into numbers having the first two chratcers being BM and the next character representing the size of the image in bytes. I have tried to search on the internet but all i found was codes in C which i do not understand. Please can anyone send me an e-mail with some sample codes on : cof123@gmail.com
:
Google for bitmap (.bmp) file format. When you find the file format information, write your code that handles such file.

NetGert[/italic]


Report
Re: Bitmaps!!!!!!!!!!! Posted by cof123 on 26 Dec 2004 at 5:01 PM
: : I have started programming a few years ago and i would like to know how to decode a bitmap image and then display it on the screen. all i have managed to do is convert the bitmap into numbers having the first two chratcers being BM and the next character representing the size of the image in bytes. I have tried to search on the internet but all i found was codes in C which i do not understand. Please can anyone send me an e-mail with some sample codes on : cof123@gmail.com
: :
: Google for bitmap (.bmp) file format. When you find the file format information, write your code that handles such file.
:
NetGert[/italic]

: :
But what i need to know is how to decode the bitmap data part of a 16 color bitmap as in one bit there will be 2 pixels represented in one byte??

Report
Re: Bitmaps!!!!!!!!!!! Posted by Johnny13 on 27 Dec 2004 at 9:22 AM
: But what i need to know is how to decode the bitmap data part of a 16 color bitmap as in one bit there will be 2 pixels represented in one byte??
const x:byte=$DA;
writeln('1st pixel=',x shr 4);
writeln('2nd pixel=',x and $F)

Report
Re: Bitmaps!!!!!!!!!!! Posted by cof123 on 28 Dec 2004 at 3:19 AM
This message was edited by cof123 at 2004-12-28 3:21:56

Thanks everyone. Now i'm having problem with the palette i'm using the
for i:= 0 to 15 do
begin
SetRGBPalette(i,ORD(current+2),ORD(Current+1),ORD(Current));
Current:=Current+4;
end;
But the first few colours are almost all black while the black one is being outputted as white. Am i doing something wrong? Or am i using the wrong command?


Report
Re: Bitmaps!!!!!!!!!!! Posted by netgert on 28 Dec 2004 at 11:15 AM
: This message was edited by cof123 at 2004-12-28 3:21:56

: Thanks everyone. Now i'm having problem with the palette i'm using the
: for i:= 0 to 15 do
: begin
: SetRGBPalette(i,ORD(current+2),ORD(Current+1),ORD(Current));
: Current:=Current+4;
: end;
: But the first few colours are almost all black while the black one is being outputted as white. Am i doing something wrong? Or am i using the wrong command?
:
:
:
if Current is initially 0 then after this code the palette has gradient colors from #020100 to #3E3D3C which is from black to dark grey
not sure if this is what u want

NetGert[/italic]


Report
Re: Bitmaps!!!!!!!!!!! Posted by cof123 on 28 Dec 2004 at 11:53 AM
: : This message was edited by cof123 at 2004-12-28 3:21:56

: : Thanks everyone. Now i'm having problem with the palette i'm using the
: : for i:= 0 to 15 do
: : begin
: : SetRGBPalette(i,ORD(current+2),ORD(Current+1),ORD(Current));
: : Current:=Current+4;
: : end;
: : But the first few colours are almost all black while the black one is being outputted as white. Am i doing something wrong? Or am i using the wrong command?
: :
: :
: :
: if Current is initially 0 then after this code the palette has gradient colors from #020100 to #3E3D3C which is from black to dark grey
: not sure if this is what u want
:
NetGert[/italic]

:
:
No current is the variable which is keeping the pointer of the ascii code in a string that is currently being read
Report
Re: Bitmaps!!!!!!!!!!! Posted by netgert on 29 Dec 2004 at 1:43 AM
: : : This message was edited by cof123 at 2004-12-28 3:21:56

: : : Thanks everyone. Now i'm having problem with the palette i'm using the
: : : for i:= 0 to 15 do
: : : begin
: : : SetRGBPalette(i,ORD(current+2),ORD(Current+1),ORD(Current));
: : : Current:=Current+4;
: : : end;
: : : But the first few colours are almost all black while the black one is being outputted as white. Am i doing something wrong? Or am i using the wrong command?
: : :
: : :
: : :
: : if Current is initially 0 then after this code the palette has gradient colors from #020100 to #3E3D3C which is from black to dark grey
: : not sure if this is what u want
: :
NetGert[/italic]

: :
: :
: No current is the variable which is keeping the pointer of the ascii code in a string that is currently being read
:
that (using strings) seems like an ugly way to do it
i would blockread() and convert data to Graph memory image (array of bytes containing the color's index in palette).... not sure if Graph's memory image uses 2-colors-to-1-byte encoding, havent worked with it a while

NetGert[/italic]


Report
Re: Bitmaps!!!!!!!!!!! Posted by cof123 on 29 Dec 2004 at 6:46 AM
: that (using strings) seems like an ugly way to do it
: i would blockread() and convert data to Graph memory image (array of bytes containing the color's index in palette).... not sure if Graph's memory image uses 2-colors-to-1-byte encoding, havent worked with it a while
:
NetGert[/italic]

:
:
Well I have been using the graph unit only this month can you tell me what exactly do you mean by Convert data to graph memory image???
Report
Re: Bitmaps!!!!!!!!!!! Posted by netgert on 30 Dec 2004 at 1:23 AM
: : that (using strings) seems like an ugly way to do it
: : i would blockread() and convert data to Graph memory image (array of bytes containing the color's index in palette).... not sure if Graph's memory image uses 2-colors-to-1-byte encoding, havent worked with it a while
: :
NetGert[/italic]

: :
: :
: Well I have been using the graph unit only this month can you tell me what exactly do you mean by Convert data to graph memory image???
:
use the TP's builtin manual to get more info on functions GetImage and PutImage
GetImage copies an area of screen into a buffer (thats what i called graph memory image) for use by your program. you can modify that buffer to alter the image, or save it to a file for later usage
PutImage copies a buffer data to the screen. you can easily read the image data from the .bmp file and construct the image in the buffer and then use PutImage to put it onto the screen

NetGert[/italic]


Report
Re: Bitmaps!!!!!!!!!!! Posted by cof123 on 30 Dec 2004 at 3:01 AM
: use the TP's builtin manual to get more info on functions GetImage and PutImage
: GetImage copies an area of screen into a buffer (thats what i called graph memory image) for use by your program. you can modify that buffer to alter the image, or save it to a file for later usage
: PutImage copies a buffer data to the screen. you can easily read the image data from the .bmp file and construct the image in the buffer and then use PutImage to put it onto the screen
:
NetGert[/italic]

:
:
But my problem isnt displaying the picture but displaying the correct colours. Is there any web page which shows sample codes in Pascal???
Report
Re: Bitmaps!!!!!!!!!!! [continued] Posted by netgert on 30 Dec 2004 at 1:39 PM
: : use the TP's builtin manual to get more info on functions GetImage and PutImage
: : GetImage copies an area of screen into a buffer (thats what i called graph memory image) for use by your program. you can modify that buffer to alter the image, or save it to a file for later usage
: : PutImage copies a buffer data to the screen. you can easily read the image data from the .bmp file and construct the image in the buffer and then use PutImage to put it onto the screen
: :
NetGert[/italic]

: :
: :
: But my problem isnt displaying the picture but displaying the correct colours. Is there any web page which shows sample codes in Pascal???
:
then read the colortable in the .bmp file. and depending on that, set the color palette values to whats defined in the file
color table is an array of RGBQUAD structures
type RGBQUAD = record
rgbBlue: Byte;
rgbGreen: Byte;
rgbRed: Byte;
rgbReserved: Byte;
end;

NetGert[/italic]


Report
Re: Bitmaps!!!!!!!!!!! [continued] Posted by cof123 on 31 Dec 2004 at 1:53 AM
: then read the colortable in the .bmp file. and depending on that, set the color palette values to whats defined in the file
: color table is an array of RGBQUAD structures
: type RGBQUAD = record
: rgbBlue: Byte;
: rgbGreen: Byte;
: rgbRed: Byte;
: rgbReserved: Byte;
: end;
:
NetGert[/italic]

:
:
I read the colour table in that way but the picture isn't the one i made. All i'm getting is random coloured pixels.
Report
Re: Bitmaps!!!!!!!!!!! [continued] Posted by netgert on 31 Dec 2004 at 4:36 AM
: : then read the colortable in the .bmp file. and depending on that, set the color palette values to whats defined in the file
: : color table is an array of RGBQUAD structures
: : type RGBQUAD = record
: : rgbBlue: Byte;
: : rgbGreen: Byte;
: : rgbRed: Byte;
: : rgbReserved: Byte;
: : end;
: :
NetGert[/italic]

: :
: :
: I read the colour table in that way but the picture isn't the one i made. All i'm getting is random coloured pixels.
:
maybe because TP's Graph unit color components are 0 to 63, not 0 to 255 as usual... so divide (/) the bitmaps color component by 255 (red/255), multiply with 63 (red/255*63) and round the number. maybe this will work

NetGert[/italic]


Report
Re: Bitmaps!!!!!!!!!!! [continued] Posted by cof123 on 1 Jan 2005 at 5:52 PM
: maybe because TP's Graph unit color components are 0 to 63, not 0 to 255 as usual... so divide (/) the bitmaps color component by 255 (red/255), multiply with 63 (red/255*63) and round the number. maybe this will work
:
NetGert[/italic]


I used this but still i got the same result. Is there anyone who has created something like a bitmap loader and can send me the source code on this e-mail cof123@gmail.com . I would really appreciate as a Christmas present.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.