 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Asko Korpela Guest
|
Posted: Thu Oct 12, 2006 12:50 am Post subject: Resize |
|
|
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
|
Posted: Fri Oct 13, 2006 3:36 am Post subject: Re: Resize |
|
|
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
|
Posted: Fri Oct 13, 2006 8:11 am Post subject: Re: Resize |
|
|
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
|
Posted: Sat Oct 14, 2006 1:22 am Post subject: Re: Resize |
|
|
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
|
Posted: Sat Oct 14, 2006 2:28 am Post subject: Re: Resize |
|
|
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
|
|
| Back to top |
|
 |
|
|
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
|
|