You are not logged in.
Pages: 1
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?
@jaclas It's impossible:
https://stackoverflow.com/questions/126 … -file-size
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;
I just have a standard .bz2 file. So I can't unpack it? Somehow programs like 7zip and WinRAR can unpack this file.
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?
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?
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?
This is really great decoder! However it has problems with grayscale JPEGs.
This is the sample file:
And this is how it's decoded:
Pages: 1