[Lazarus] Loading file into TImageList does not properly scale
waldo kitty
wkitty42 at windstream.net
Mon Nov 23 01:37:41 CET 2009
Matt Shaffer wrote:
> Hello, the code below is how I load and convert PNG files into BMPs, add
> them to a TImageList, and then add them to a TListView.
as a "relative newbie" here (but not to coding in PASCAL), why do you have to
convert to BMP? does the existing library (ie: LCL and FPC) code not accept PNG,
GIF and similar for these graphic purposes?
> The problem I'm
> having is that I cannot get the little bugger to scale to 96x96; other
> than that the code works. I would imagine that setting the timage's
> stretch property to true ought to scale the image to 96x96, but that was
> not the case.
sounds like it looks at the image properties for smaller scale with which to
increase via the "stretch" routine... unlike other "stretch" routines which also
reduce in size to the chosen params...
> lsTextures: TListView;
> imgTextures: TImageList;
>
> procedure TForm1.MenuItem15Click(Sender: TObject);
> var
> bmp: TBitmap;
> img: TImage;
> itm: TListItem;
> begin
> bmp := TBitmap.Create;
> img := TImage.Create(nil);
> try
> lsTextures.BeginUpdate;
> img.Stretch := true;
> img.Width := 96;
> img.Height := 96;
> bmp.Width := 96;
> bmp.Height := 96;
> img.Picture.LoadFromFile('screen.png');
> itm := lsTextures.Items.Add;
> bmp.Assign(img.Picture.Bitmap);
> imgTextures.AddMasked(bmp,clFuchsia);
> itm.Caption := 'New Image';
> itm.ImageIndex := imgTextures.Count-1;
> finally
> bmp.Free;
> lsTextures.EndUpdate;
> end;
> end;
>
>
> ------------------------------------------------------------------------
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
More information about the Lazarus
mailing list