From: "Pablo Pedrocca" Subject: Re: Quick way to make an image more blue Date: 09 Aug 1999 00:00:00 GMT Message-ID: <7omjdj$7ip3@forums.borland.com> References: <7old09$6ci3@forums.borland.com> Organization: Another Netscape Collabra Server User X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: borland.public.delphi.graphics Hi, Try this: set the Bitmap to 24 bits, go trough the bitmap using scanline[x] and a) add a constant to the blue value or b) substract a constant to the red and green values or c) set the red and green values to 0. image3.Bitmap.HandleType:=bmDIB; image3.Bitmap.PixelFormat:=pf24Bit; Copywidth:=image3.Width; CopyHeight:=image3.Height; // Process each pixel: For Y:=0 to CopyHeight-1 do begin P:=image3.Bitmap.ScanLine[Y]; For X:=0 to (CopyWidth*3)-1 do begin P[X]:=0; ///that's black. The right number is 000000000000000 11111111 end; If your bitmap can't set to 24 bits, you have to work on the palette. var pal: PLogPalette; ///Buffer Palette img2pal: PlogPalette; ///Palette of image2 hpal: HPALETTE; ///Handle to a new palette h2pal: HPALETTE; ///Handle of image2 palette i: Integer; x: Integer; begin ///Reset variables pal := nil; img2pal:=nil; try ///Takes place in memory to the palettes GetMem(img2pal,sizeof(TLogPalette) + sizeof(TPaletteEntry) * 255); GetMem(pal, sizeof(TLogPalette) + sizeof(TPaletteEntry) * 255); pal.palVersion := $300; pal.palNumEntries := 256; ///256 colors img2pal.palVersion := $300; img2pal.palNumEntries := 256; ///Scan the entries of the palette and reset it. for i := 0 to 255 do begin img2pal.palPalEntry[i].peRed := 0; img2pal.palPalEntry[i].peGreen := 0; img2pal.palPalEntry[i].peBlue := 0; end; ///read the entries from the image (the buffer image) x:=0 ; x := getpaletteentries(Image2.picture.Bitmap.Palette,0,255,img2pal.palPalEntry); //\ x := getpaletteentries(Bitmap.Palette,0,255,img2pal.palPalEntry); if x=0 then begin Showmessage('Funcion falla - function fails'); exit; end; ///Now, shift the entries by adding 4. You can change this value. for i := 0 to 255 do begin pal.palPalEntry[i].pered := img2pal.palPalEntry[i].pered+shiftvalue; pal.palPalEntry[i].pegreen := img2pal.palPalEntry[i].pegreen; ///or :=0 pal.palPalEntry[i].peBlue := img2pal.palPalEntry[i].peblue; ///or :=0 end; ///Create a new palette using pal (the buffer palette). hpal := CreatePalette(pal^); ///If successful, assign the new palette to the buffer if hpal <> 0 then image2.Picture.bitmap.Palette := hpal //\ bitmap.palette := hpal else Showmessage('Funcion falla'); finally FreeMem(pal); end; end; William escribió en mensaje <7old09$6ci3@forums.borland.com>... >Hi > >I am using a listbox with owner draw. To indicate selected items, I want >them to appear more blue (as they do when you select an item in Windows >Explorer). I don't want to just have a blue background, I want to actually >take the BMP (i have dynamically created from teh originaly file) and give >it a bluish hue. > >So what is a quick way to make a small BMP image turn blue? > >Thanks for your help > >Regards > >William >the_white_house@usa.net