#1 2013-12-01 08:56:30

djjoy
Member
Registered: 2013-12-01
Posts: 1

Stretch jpeg

Hi,
Sorry for my english, i'm Spanish.
I want made thumbnails from jpg's.
Your decoder is very, very fast decoding jpeg.
I'm developing a mp3 player. With your decoding routine, i read jpeg picture from id3v2tag.
I want resize all images to 150x150. There is a faster routine for resizing ?
Can you give me the way to add a function like drawto( canvas: tcanvas, x,y,: integer) but stretching ( by example stretchto( canvas: tcanvas, x,y, w,h: integer).

Best Regards

Offline

#2 2013-12-01 12:15:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Stretch jpeg

With the current code, if you want to stretch the drawing, you will need first to create a bitmap from the jpeg, then stretch the bitmap.
There is no built-in "resize" feature in this unit.

AFAIR the official JPEG library does allow to uncompress the original jpeg picture into 1/2, 1/4 or 1/8 of its original size.
But our SSE2 library does not feature this.

On option may be to try our MyJpeg unit - see http://bouchez.info/myjpeg.html
It is now old - perhaps not compatible with your Delphi version - but it handles the "Scale: TJPEGScale" property.

Online

#3 2014-08-12 19:44:26

Himeko
Member
Registered: 2014-08-12
Posts: 21

Re: Stretch jpeg

GR32 is very fast for anti-aliased resampling: http://graphics32.org/wiki/Main/Graphics32

I use TKernelResampler + TLanczosKernel for scaling down.

basically,

     GR32, GR32_Resamplers,

load jpeg into a TBitmap32 (assign)
R: TKernelResampler;
R := TKernelResampler.Create(Src);
R.Kernel := TLanczosKernel.Create;
Dst.Draw(Dst.BoundsRect, Src.BoundsRect, Src);

Dst = empty bitmap32
Src = bitmap32 containing the jpeg

Last edited by Himeko (2014-08-12 19:49:13)

Offline

#4 2014-08-13 07:14:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Stretch jpeg

Yes, I know.
What I meant was the ability of libjepg to uncompress a picture directly in 1/2, 1/4 or 1/8 of the original size.
It would use much less memory, since the 1/1 bitmap is never created.
And it would be much faster.

Online

Board footer

Powered by FluxBB