?
Solved

Generate Thumbmails JPEG/JPEG

Posted on 1998-12-10
7
Medium Priority
?
556 Views
Last Modified: 2010-04-04
I need a few simple rutines to do following:
like Procedure big2small( Infile,outfile : string; MaxH, MaxW : integer);

Infile = Jpeg
Outfile = jpeg
MaxH = Max height of output pic, keep aspect ratio,
MaxW = max width -"-

More options allowed if any good ideas..

PS: In delphi 3.x  NOT delphi 4 and nOT OCX

Not interested in Buyware components Thanks.
0
Comment
Question by:brainware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Author Comment

by:brainware
ID: 1350482
Edited text of question
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1350483
Why not use the thumbnails function provided by WangImage(TM),
it's an OCX included in Win95. It's now the world leading Image process software and totally free!
0
 
LVL 2

Author Comment

by:brainware
ID: 1350484
I will look into that, i tryed it long time ago, forgot that one :)
well.. hope its in NT too else ill just have to use win9x to do the job.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:brainware
ID: 1350485
Edited text of question
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 600 total points
ID: 1350486
Hi

(I assume you already know about the JPeg folder on the Delphi 3 CDROM.  You will need the JPeg unit from the CDROM to do what I explain below.  Delphi 4 includes the JPeg unit when you install Delphi.)

The StretchBlt API allows you to resize an image (e.g. bitmap).  Unfortunately you need a canvas to work with, and Delphi's TJPegImage doesn't have a canvas.  I have overcome this problem before by using "dummy" bitmaps as follows:

procedure CreateThumbnail(jpBig, jpSmall: TJpegImage; NewWidth, NewHeight: Integer);
var
  BmpBig, BmpSmall: TBitmap;
begin
  // Create the temp bitmaps.
  BmpBig := TBitmap.Create;
  BmpSmall := TBitmap.Create;

  // Assign the "big" bitmap to the "big" JPEG.
  BmpBig.Assign(jpBig);

  // Create the "small" bitmap.
  BmpSmall.Width := NewWidth;
  BmpSmall.Height := NewHeight;
  StretchBlt(BmpSmall.Canvas.Handle, 0, 0, NewWidth, NewHeight, BmpBig.Canvas.Handle, 0, 0, jpBig.Width, jpBig.Height, SRCCOPY);

  // Assign the "small" JPEG to the "small" bitmap.
  jpSmall.Assign(BmpSmall);

  // Free the temp bitmaps.
  BmpBig.Free;
  BmpSmall.Free;
end;


This would then be called as follows:

var
  jpBig, jpSmall: TJPegImage;
begin
  jpBig := TJPegImage.Create;
  jpSmall := TJPegImage.Create;

  jpBig.LoadFromFile('Test.jpg');

  CreateThumbnail(jpBig, jpSmall, 120, Round((120 / jpBig.Width) * jpBig.Height));

  jpSmall.SaveToFile('Test2.jpg');

  jpSmall.Free;
  jpBig.Free;
end;

(NOTE: You will need to add "JPeg" to your uses clause.)

Cheers,
JB

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1350487
JimBob's solution is perfect... If you use the OCX you have to supply the OCX if you try to run the software on another computer that doesn't have that OCX...so better use simple solution... No need to get your hands dirty with the OCXes....

Cheers,
Viktor
0
 
LVL 2

Author Comment

by:brainware
ID: 1350488
I Tryed your code with StretchBlt, Its almost worth using :)
Well it (Edited by Computer101) Colors and (Edited by Computer101) up...
I think i know how to fix, But you are welcome to Add as Comment..
Mvh
Michael
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question