#1 GDI+ » Get Bits Per Pixel (or PixelFormat)? » 2020-05-17 15:03:14

domek
Replies: 0

It's pretty amazing how easily this library can load JPEGs, PNGs and GIFs but can I get number of bits per pixel or PixelFormat?

#3 Fast JPEG decoder » Making it usuable » 2020-02-17 15:15:27

domek
Replies: 1

So JpegDec is fast but can't handle:
- progressive JPEGs
- CMYK JPEGs
- Grayscale JPEGs

In many cases JpegDec is as fast as SynGdiPlus.TJpegImage but I noticed it's faster than SynGdiPlus on bigger images.
So I glued both things together. I used thread-safe version of JpegDec from:
http://www.marktg.com/jpegdec/

Remeber to put somewhere in your code this line:

Gdip.RegisterPictures;

Uses libraries:

JpegDec, SynGdiPlus
function LoadJPEG(Filename: String; out Bmp: TBitmap): Boolean;
var F: TFileStream;
    Mem: TMemoryStream;
    Bpp: Integer;
    Jpg: SynGdiPlus.TJpegImage;
begin
  Result := False;
  Mem := TMemoryStream.Create;

  try
    F := TFileStream.Create(Filename, fmOpenRead or fmShareExclusive);
    Mem.SetSize(F.Size);
    Mem.CopyFrom(F, F.Size);
  finally
    F.Free;
  end;

  if Mem.Size < 1 then begin
    Mem.Free;
    Exit;
  end;

  Bmp := JpegDecode(Mem.Memory, Mem.Size);
  if Bmp <> nil then begin
    Result := True;
    Mem.Free;
    Exit;
  end;

  Mem.Position := 0;
  Jpg := SynGdiPlus.TJpegImage.Create;
  try
    Jpg.LoadFromStream(Mem);
    Bmp := Jpg.ToBitmap;
  finally
    Jpg.Free;
    Result := True;    
  end;

  Mem.Free;
end;

#4 Re: mORMot 1 » SynBzPas.pas and UnCompressBzMem - what is the unpacked size? » 2020-02-15 14:29:53

I just have a standard .bz2 file. So I can't unpack it? Somehow programs like 7zip and WinRAR can unpack this file.

#5 mORMot 1 » SynBzPas.pas and UnCompressBzMem - what is the unpacked size? » 2020-02-14 13:42:56

domek
Replies: 5

I want to use UnCompressBzMem() from SynBZPas.pas to unpack z .bz2 file. But in order to do so I need to know the last parameter:
DestSize: integer
so the size after unpacking. Where do I get this size from an actual .bz2 file?

#6 Re: Low level and performance » PasZip and UncompressMem » 2020-01-17 13:17:10

From my tests I think UncompressMem() expects Raw deflate and therefore I should use:
UncompressMem(@InBuffer[2], @OutBuffer[0], InBufferLen-6, OutBufferLen);
Is this correct approach?

#7 Low level and performance » PasZip and UncompressMem » 2020-01-17 12:58:55

domek
Replies: 1

I have data compressed with ZLIB wrapped using ZLIB headers.
The data is not corrupted. I can decompress using PHP's gzuncompress:
https://www.php.net/manual/en/function.gzuncompress.php
but when I try UncompressMem() it fails.

So what kind of data UncompressMem() expects if not Zlib? Raw deflate, Zip, Gzip?
Also how I can unpack Zlib uzing PasZip?

#8 Re: Fast JPEG decoder » Please work again on this » 2019-04-09 23:14:49

This is really great decoder! However it has problems with grayscale JPEGs.

This is the sample file:
Gza720B.jpg

And this is how it's decoded:
NrNH8Dz.jpg

Board footer

Powered by FluxBB