From: Robert Rossmair Subject: Re: Bug in pf15Bit bitmaps ??? Date: 27 May 2000 00:00:00 GMT Message-ID: <8goqbc$u2f$18$1@news.t-online.com> Content-Transfer-Encoding: 8bit References: <8gm25u$7kt10@bornews.borland.com> X-Posting-Agent: Hamster/1.3.14.0 X-Accept-Language: de,en X-Sender: 340065752685-0001@t-dialin.net Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@t-online.de X-Trace: news.t-online.com 959442093 18 30799 340065752685-0001 000527 15:41:33 Organization: - Mime-Version: 1.0 Newsgroups: borland.public.delphi.graphics Hi Earl, "Earl F. Glynn" schrieb: > "Colin Wilson" wrote in message > news:VA.00000cae.049786d4@dtop2000beta308... > > It doesn't seem to be possible to create a pf15Bit format bitmap in D5. > > You can set the pixel format to pf15Bit, but as soon as you set the > > width and hight, it changes to pfCustom. You can even set the pixel > > format to pf15Bit after setting the width and height, but when you > > examine it, again it's pfCustom. > > I tried your code and observed what you described on 1 of 3 machines. > My newest Dell has the same problem you describe, but older > "no name" machines created pf15bit bitmaps quite easily. > > FWIW, all of the machines created pf16bit bitmaps. > > We need a device driver expert to explain exactly what's going on. I don't think so. The reason is that some video drivers encode 15-bit color format by means of setting the BITMAPINFOHEADER.biCompression field to BI_BITFIELDS and specifying dsBitfields accordingly. Modifying TBitmap.GetPixelFormat as follows and copying the modified Graphics.pas to the project directory solves the problem for me: function TBitmap.GetPixelFormat: TPixelFormat; begin Result := pfCustom; if HandleType = bmDDB then Result := pfDevice else with FImage.FDIB, dsbmih do case biBitCount of 1: Result := pf1Bit; 4: Result := pf4Bit; 8: Result := pf8Bit; 16: case biCompression of BI_RGB : Result := pf15Bit; BI_BITFIELDS: case dsBitFields[1] of $3E0: Result := pf15Bit; $7E0: Result := pf16Bit; end; end; 24: Result := pf24Bit; 32: if biCompression = BI_RGB then Result := pf32Bit; end; end; Of course this has the disadvantage that you can't use runtime libraries with your program. Another solution would be to use some workaround function: function GetTruePixelFormat(ABitmap: TBitmap): TPixelFormat; var DIB: TDIBSection; PixelFormat : TPixelFormat; begin Result := ABitmap.PixelFormat; if Result = pfCustom then begin GetObject(ABitmap.Handle, SizeOf(DIB), @DIB); with DIB, dsbmih do if biBitCount = 16 then if biCompression = BI_BITFIELDS then if dsBitFields[1] = $3E0 then Result := 15; end; end; I run into this problem some time ago and hoped that it would be solved in Delphi 5, but that wasn't the case (I'm not reporting issues to Borland's bug report page any longer since experience shows that there isn't any response). Greetings, Robert -- Robert Roßmair http://home.t-online.de/home/Robert.Rossmair/ Programming environment: Delphi 5.01 Professional, WinNT 4.0 SP6