On Sat, 7 Jul 2012 14:40:14 +0200 tazio mirandola <dev...@gmail.com> wrote:
> hi all, > > i'm trying to resize a jpg via fpc-image, this is the relevant code(adapted > from http://wiki.freepascal.org/fcl-image): > > > uses > fpimage, fpcanvas, FPImgCanv, fpreadjpeg,fpwritejpeg; > > procedure TImgResize.Resample(AFileName:string); > var > Image : TFPCustomImage; > writer : TFPCustomImageWriter; > Reader : TFPReaderJPEG; > Canvas : TFPCustomCanvas; > begin > // Create an image > Image := TFPMemoryImage.Create(224,150); > > Reader := TFPReaderJPEG.Create; > Image.LoadFromFile(AFileName (*, Reader*) ); > > //Image.SetSize(224,150); > > // Attach the image to the canvas > Canvas := TFPImageCanvas.Create(image); > > // Create the writer > Writer := TFPWriterJPEG.Create; > > // Save to file > Image.SetSize(224,150); > Image.SaveToFile(AFileName+'b.jpg' (*, writer*) ); > > Canvas.Free; > Image.Free; > Writer.Free; > end; > > actually, Image.SetSize(224,150); causes half of the resulting image being > black! > is it a bug or am i colling it wrongly? It seems a bug in TFPMemoryImage.SetSize. The move moves only w byte, but it should move w*SizeOf(TFPColor) byte. Please report. BTW, SetSize does not scale the image. Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal