Board index » delphi » 15-bit-color value to TColor value
DPR
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
|
DPR
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
15-bit-color value to TColor value
Hi,
... how can I convert a 15-Bit color value (gggggbbbbbrrrr binary) to a TColor value ? Thanks in advance, DPR |
Hedayat Ahmadpou
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueQuoteDPR <hw.del...@gmx.de> wrote in message Quote> Hi, var R, G, B: integer; begin {gggggbbbbbrrrrr } R:= C15 and $1F; G:= (C15 shr 10) and $1F; B:= (C15 shr 5) and $1F; Result:= (R shl 3)+ (G shl 11)+ (B shl 19); end; |
DPR
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueYour function does not work - just try to convert a white pixel (value $7FFF). The result is $F8F8F8 but should be $FFFFFF. Any idea ? DPR |
Earl F. Glyn
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueQuote"DPR" <hw.del...@gmx.de> wrote in message news:8it7ro$e485@bornews.borland.com... F = 1111 (four bits) + 8 = 1000 (one bit) = 5 bits. The $F8F8F8 answer still only has 15 bits of information. That's Conversion from 24-bits to 15-bits requires throwing away I hope this makes sense. -- Earl F. Glynn E-mail: EarlGl...@att.net efg's Computer Lab: http://www.efg2.com/Lab |
Hedayat Ahmadpou
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueEarl, Thanks for the assist. function Convert15bitToTColor( C15: integer): TColor; |
Maynard Philbroo
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueWell let see here.. Mycolor := RGB(V and 31, (V shr 10) and 31, (V shr 5) and 31); i think that is close. QuoteDPR wrote: |
Earl F. Glyn
![]() Delphi Developer |
Mon, 09 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueQuote"Hedayat Ahmadpour" <h_ahmadp...@yahoo.com> wrote in message news:8itdem$e6n6@bornews.borland.com... not just white. For example, pure red in 15-bits would be This becomes $0000F8 in 24-bits, not -- Earl F. Glynn E-mail: EarlGl...@att.net efg's Computer Lab: http://www.efg2.com/Lab |
limbiqu
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueof course it will be $000000ff.. or else it's not max.red... Limbique. |
limbiqu
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueok, this is how to do it : convert to 24 bit. (tcolor = BGR) r := value and 1F; NewColor := (r shl 3) or (g shl 11) or (g shl 19); TADA!!! limbique. QuoteDPR <hw.del...@gmx.de> wrote in message Quote> Hi, |
DPR
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueWell, thanks for your answers. Yes, of course the function works with all values - but not that way I want Bye, DPR |
limbiqu
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueQuote> Let's say you have the 15-bit color with the following values (dec.) : R |
DPR
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueQuote> max of 15bit (r=5bit) = 31...... is that the problem? |
Earl F. Glyn
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueQuote"DPR" <hw.del...@gmx.de> wrote in message news:8iv68d$aio4@bornews.borland.com... If you start with 5 bits and want 8 bits, the "added" 3 bits are arbitrary -- there's I have never studied exactly what Windows does when you take a pf15bit bitmap -- Earl F. Glynn E-mail: EarlGl...@att.net efg's Computer Lab: http://www.efg2.com/Lab |
Earl F. Glyn
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor value"Earl F. Glynn" <EarlGl...@att.net> wrote in message news:8ivona$ehe4@bornews.borland.com... Quote> I have never studied exactly what Windows does when you take a pf15bit bitmap shades of gray in 15-bit and see what they become in a 24-bit bitmap. There are 32 shades of gray in 15-bit, RGB(index,index,index), where index = 0..31. procedure TForm1.Button1Click(Sender: TObject); Memo1.Clear; FOR j := 0 TO Bitmap.Height-1 DO Image1.Picture.Graphic := Bitmap; So defining these 32 shades of gray results with the following in the Memo box: 15-bit shades of gray All of the above is as expected. Bitmap.PixelFormat := pf24bit BUT, if you let Windows (Delphi?) do this, the process is NOT So the following code analyzes the 24-bit shades of gray from the Memo1.Lines.Add('15-bit shades of gray converted to 24-bits'); FOR j := 0 TO Bitmap.Height-1 DO END FINALLY Each line in the output below is like this: One one machine, the results were: 15-bit shades of gray converted to 24-bits On another machine the results were: So you might get black ($000000) and white ($FFFFFF) the same When working on image processing projects, I would want code to -- Earl F. Glynn E-mail: EarlGl...@att.net efg's Computer Lab: http://www.efg2.com/Lab |
DPR
![]() Delphi Developer |
Tue, 10 Dec 2002 03:00:00 GMT
Re:15-bit-color value to TColor valueQuote> function Convert5bitsTo8Bits( byte: integer):byte; created: function ConvertC15To24(C15: Word): TColor; |
1. TCOlor value - 256 color vs 16/32bit
2. getting color value (conversion from int to TColor)
4. 32 bit code in a 15 bit compiler
5. Indy 8.004 bug applying 32 bit value to winsock 16 bit causing range check error
6. Setting TColor values question
7. Getting a RGB-value from a TCOLOR
8. Writing a TColor value to an .INI file