Solved

Generate Thumbmails JPEG/JPEG

Posted on 1998-12-10
7
518 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
Comment Utility
Edited text of question
0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 2

Author Comment

by:brainware
Comment Utility
Edited text of question
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now