Recent

Author Topic: bgrabitmap reduce quality  (Read 737 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2145
    • Lazarus and Free Pascal italian community
bgrabitmap reduce quality
« on: December 28, 2019, 06:59:50 pm »
Hi guys, I have a question. How can I reduce the quality of an image? I am looking for something similar to

TJPEGImage.CompressionQuality

But for bgrabitmap
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

winni

  • Hero Member
  • *****
  • Posts: 2116
Re: bgrabitmap reduce quality
« Reply #1 on: December 28, 2019, 08:06:26 pm »
Hi!

JP(E)G  is a lossy file format.
BGRA is a format to store, convert an show images.

You can save a BGRAbitmap with low quality/high compression as a JPG, but who wants that?

Winni


lainz

  • Hero Member
  • *****
  • Posts: 3918
  • Leandro Diaz
Re: bgrabitmap reduce quality
« Reply #2 on: December 28, 2019, 10:42:13 pm »
In LazPaint is used this:

Code: Pascal  [Select][+][-]
  1. FJpegStream := TMemoryStream.Create;
  2.     writer := TFPWriterJPEG.Create;
  3.     writer.CompressionQuality := JpegQuality;
  4.     FFlattenedOriginal.SaveToStream(FJpegStream, writer);
  5.     writer.Free;

FFlattenedOriginal is a TBGRABitmap.

uses
  fpwritejpeg;

circular

  • Hero Member
  • *****
  • Posts: 3645
    • Personal webpage
Re: bgrabitmap reduce quality
« Reply #3 on: December 29, 2019, 04:55:57 pm »
Indeed you need to pass the image writer as a parameter to specify the desired format options. Works as will with SaveToFile.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018