From: "Earl F. Glynn" Subject: Re: Failure with pf1bit but not other PixelFormats? Date: 13 Oct 1999 00:00:00 GMT Message-ID: <7u2fgl$89k13@forums.borland.com> References: <7ttd59$p7u11@forums.borland.com> Organization: Another Netscape Collabra Server User X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Newsgroups: borland.public.delphi.graphics Earl F. Glynn wrote in message news:7ttd59$p7u11@forums.borland.com... > ... asked why the following code fails when pf1bit PixelFormat is used, > but not other PixelFormats > Grid := TBitmap.Create; > > // With pf1bit the image is all black. With all other > // PixelFormats the desired grid is displayed. > Grid.PixelFormat:=pf4bit; > > try > Grid.Height:=10; > Grid.Width:= Grid.Height; Based on observations in the Very Large Bitmap experiment, http://www.efg2.com/Lab/Graphics/VeryLargeBitmap.htm I defined a bitmap's PixelFormat before its height and width, since sometimes larger bitmaps could be created this way. (Before that experiment, I wasn't really consistent in the order in which I defined a bitmap's properties.) HOWEVER, this order causes some sort of problem with pf1bit bitmaps. If you define PixelFormat := pf1bit before setting the bitmap's height and width, the original code works fine for pf1bit bitmaps. Grid := TBitmap.Create; try Grid.Height:=10; Grid.Width:= Grid.Height; // Unclear why this must follow width/height to work correctly. // If PixelFormat precedes width/height, bitmap will always be black. Grid.PixelFormat:=pf1bit; So there is a work around for this problem (but I'm not sure why it works or why the original code failed.) ___ efg Earl F. Glynn Overland Park, KS USA efg's Computer Lab: http://www.efg2.com/Lab