On 31 Dec 2005 11:22:24 +0100 Darius Blaszijk <[EMAIL PROTECTED]> wrote:
> > Red, Green, Blue, Alpha are words (0-65536). Use 32768. > I tried, but the bitmap is just copied (as it should) and setting the > pixels to 32768 does not affect the appearance. > > Darius > > > On Sat, 2005-12-31 at 10:49, Mattias Gaertner wrote: > > On Sat, 31 Dec 2005 01:05:09 +0100 (CET) > > [EMAIL PROTECTED] wrote: > > > > > Hi, > > > > > > The following function does not work. It seems that the image is not > > > affected at all, although all color channels are set to 128. I would > > > expect to get a uniformly gray image, the size of the initial bitmap. > > > What am I missing here? > > > > > > function ConvertBitmap(ABitmap: TBitmap): TBitmap; > > > var > > > TempIntfImg: TLazIntfImage; > > > ImgHandle,ImgMaskHandle: HBitmap; > > > x, y: Integer; > > > begin > > > TempIntfImg:=TLazIntfImage.Create(0,0); > > > TempIntfImg.LoadFromBitmap(ABitmap.Handle,ABitmap.MaskHandle); > > > > > > Result:=TBitmap.Create; > > > > > > //change all pixels to gray > > > for y:=0 to Pred(TempIntfImg.Height) do > > > for x:=0 to Pred(TempIntfImg.Width) do > > > begin > > > TempIntfImg.Colors[x, y].Red:=128; > > > > Red, Green, Blue, Alpha are words (0-65536). Use 32768. Sorry. I forgot: Reading TempIntfImg.Colors[x, y] returns a record. Setting TempIntfImg.Colors[x, y].red changes only a temporary record. You must write to the TempIntfImg.Colors[x, y]. For example: col:=TempIntfImg.Colors[x, y]; col.red:=32768; TempIntfImg.Colors[x, y]:=col; Mattias > > > > > > > TempIntfImg.Colors[x, y].Green:=128; > > > TempIntfImg.Colors[x, y].Blue:=128; > > > end; > > > > > > TempIntfImg.CreateBitmap(ImgHandle,ImgMaskHandle,false); > > > > > > Result.Handle:=ImgHandle; > > > Result.MaskHandle:=ImgMaskHandle; > > > > > > TempIntfImg.Free; > > > end; > > > > Mattias > > > > _________________________________________________________________ > > To unsubscribe: mail [EMAIL PROTECTED] with > > "unsubscribe" as the Subject > > archives at http://www.lazarus.freepascal.org/mailarchives > > > _________________________________________________________________ > To unsubscribe: mail [EMAIL PROTECTED] with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
