BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Resize

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Asko Korpela
Guest





PostPosted: Thu Oct 12, 2006 12:50 am    Post subject: Resize Reply with quote



How can I resize jpg fotos in D 2006?
In D7 I used CBImage, but it does not work any more.

--
Asko Korpela
http://www.askokorpela.fi/
+358(0)50 529 9539
Back to top
Charles Hacker
Guest





PostPosted: Fri Oct 13, 2006 3:36 am    Post subject: Re: Resize Reply with quote



Asko Korpela wrote:
Quote:

How can I resize jpg fotos in D 2006?


You can copy your JPEG to a bitmap, resize the bitmap, then copy that
back
to your JPEG.

uses jpeg;

var Jpg : TJPEGImage;
Bmp : TBitmap;

procedure ResizeBMP(b : TBitmap; NewWidth, NewHeight : integer);
var
tbmp : TBitmap;
begin
// Not the best Bitmap resizer
// Got to EFG site and download a Bitmap 'resampler' code
// for better resized image
tbmp := TBitmap.Create;
tbmp.Width := b.Width;
tbmp.Height := b.Height;
BitBlt(tbmp.Canvas.Handle,0,0,tbmp.Width,tbmp.Height,
b.Canvas.Handle,0,0,SRCCOPY);
b.Width := NewWidth;
b.Height := NewHeight;
StretchBlt(b.Canvas.Handle,0,0,b.Width,b.Height,tbmp.Canvas.Handle,
0,0,tbmp.Width,tbmp.Height,SRCCOPY);
tbmp.Free;
end;

// Example code
begin
Jpg := TJPEGImage.Create;
Bmp := TBitmap.Create;
Jpg.LoadFromFile('FileName.jpg');
// Copy JPEG to bitmap:
Bmp.Width := Jpg.Width;
Bmp.Height := Jpg.Height;
Bmp.Canvas.Draw(0,0,Jpg);
// Resize Bitmap
ResizeBMP(Bmp,[newsizeW],[newsizeh]);
// Copy BMP back to JPG
Jpg.Assign(Bmp);
Jpg.SaveToFile('NewFileName.jpg');
Jpg.Free;
Bmp.Free;
end;


--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
Back to top
Michael Hansen
Guest





PostPosted: Fri Oct 13, 2006 8:11 am    Post subject: Re: Resize Reply with quote



Asko Korpela wrote:
Quote:
How can I resize jpg fotos in D 2006?
In D7 I used CBImage, but it does not work any more.

If you are looking for high quality (or fast low/medium quality) resampling
features, you could take a look at Graphics32 (www.graphics32.org).

Regards,

Michael Hansen
Back to top
Asko Korpela
Guest





PostPosted: Sat Oct 14, 2006 1:22 am    Post subject: Re: Resize Reply with quote

Thank you again. I am almost 70, have been programming over 40 years. This
time happened something that almost never before has happended: the very
first trial after having written the code brought the correct result. But...
as you hinted, the quality is not good enough to be really used. According
to your advise I went to EFG, but could not find any code for bitmap
resampler. Have you got something specific in your mind?

--
Asko Korpela
http://www.askokorpela.fi/
+358(0)50 529 9539
"Charles Hacker" <reply.to (AT) borland (DOT) newsgroups> kirjoitti
viestissä:452EC383.F868A774 (AT) borland (DOT) newsgroups...
Quote:
Asko Korpela wrote:

How can I resize jpg fotos in D 2006?


You can copy your JPEG to a bitmap, resize the bitmap, then copy that
back
to your JPEG.

uses jpeg;

var Jpg : TJPEGImage;
Bmp : TBitmap;

procedure ResizeBMP(b : TBitmap; NewWidth, NewHeight : integer);
var
tbmp : TBitmap;
begin
// Not the best Bitmap resizer
// Got to EFG site and download a Bitmap 'resampler' code
// for better resized image
tbmp := TBitmap.Create;
tbmp.Width := b.Width;
tbmp.Height := b.Height;
BitBlt(tbmp.Canvas.Handle,0,0,tbmp.Width,tbmp.Height,
b.Canvas.Handle,0,0,SRCCOPY);
b.Width := NewWidth;
b.Height := NewHeight;
StretchBlt(b.Canvas.Handle,0,0,b.Width,b.Height,tbmp.Canvas.Handle,
0,0,tbmp.Width,tbmp.Height,SRCCOPY);
tbmp.Free;
end;

// Example code
begin
Jpg := TJPEGImage.Create;
Bmp := TBitmap.Create;
Jpg.LoadFromFile('FileName.jpg');
// Copy JPEG to bitmap:
Bmp.Width := Jpg.Width;
Bmp.Height := Jpg.Height;
Bmp.Canvas.Draw(0,0,Jpg);
// Resize Bitmap
ResizeBMP(Bmp,[newsizeW],[newsizeh]);
// Copy BMP back to JPG
Jpg.Assign(Bmp);
Jpg.SaveToFile('NewFileName.jpg');
Jpg.Free;
Bmp.Free;
end;


--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
Back to top
Asko Korpela
Guest





PostPosted: Sat Oct 14, 2006 2:28 am    Post subject: Re: Resize Reply with quote

Thank you for your advise.
I got graphics 32-1-8-1 package, where there is some resampling methods, but
in no way could install the package according to the instructions.
Would there be something else?

--
Asko Korpela
http://www.askokorpela.fi/
+358(0)50 529 9539
"Michael Hansen" <dyster_tid (AT) hotmail (DOT) com> kirjoitti
viestissä:452f3886$1 (AT) newsgroups (DOT) borland.com...
Quote:
Asko Korpela wrote:
How can I resize jpg fotos in D 2006?
In D7 I used CBImage, but it does not work any more.

If you are looking for high quality (or fast low/medium quality)
resampling features, you could take a look at Graphics32
(www.graphics32.org).

Regards,

Michael Hansen
Back to top
Charles Hacker
Guest





PostPosted: Sat Oct 14, 2006 8:11 am    Post subject: Re: Resize Reply with quote

Asko Korpela wrote:
Quote:

to your advise I went to EFG, but could not find any code for bitmap
resampler. Have you got something specific in your mind?

Go to:
http://www.efg2.com/Lab/Library/Delphi/Graphics/ImageProcessing.htm

And do a search for:
Antialiasing , or
Resampling,


Note this page points to 'Anders Melander' resample Delphi code example:
Web page:
http://delphi.icm.edu.pl/authors/a0000900.htm
Actual example resampling code:
http://delphi.icm.edu.pl/ftp/d20free/resample.zip

Note: I use the above resampler code in my image processing app of
http://www.gu.edu.au/school/eng/mmt/ImProc.html

--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.