Solved

Generate Thumbmails JPEG/JPEG

Posted on 1998-12-10
7
533 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 2

Author Comment

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

Accepted Solution

by:
JimBob091197 earned 150 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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