Solved

Compression of pictures

Posted on 2000-03-11
5
230 Views
Last Modified: 2010-04-04
when i press printScreen and then go to my program and paste the picture in the clipboard in a DBImage, and save this picturem, i found that this picture takes a large storge capicity, because it's a BMP file in the clipboard,,, What i Want is to paste the picture in the clipboard in the DBImage , but as JPG or GIF format.

Simple Code or Headlines is Preferable.

Thank you all.
0
Comment
Question by:ams4380361
5 Comments
 

Expert Comment

by:sunsetyang
Comment Utility
If You are using Delphi 4 or above,you can simply do it.Delphi 4 includes a unit called jpeg,with this unit ,you can use jpg support in your program.Simply add one statement in the uses clause:jpeg.
 You can use jpeg as below:
 var:
   myjpeg:TJpegImage;
 begin
  ...
  myjpeg:=TJpegImage.Create;
  //myjpeg property setting
  //After you get the image you want to save,you can assign the bitmap to the myjpeg
  mybitmap.assign(myjpeg.graphic);
  myjpeg.compress;
  myjpeg.savetofile('filename.jpg');
  ...
  To gif,you can reference the GIF format document and to build a unit yourself.Or to serach for the right unit.
 
 
0
 

Author Comment

by:ams4380361
Comment Utility
in fact i am using Delphi 3.0, and your method is not pasting the picture from the clipboard to dbimage directly.
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
hi ams4380361,
what database do you use?
meikl
0
 
LVL 15

Expert Comment

by:simonet
Comment Utility
Following...
0
 
LVL 1

Accepted Solution

by:
saulite earned 50 total points
Comment Utility
use JPEG unit. When you press Print-Screen, image in memory is a bitmap. You can read it from clipboard, and convert it to JPG.

uses {...}, jpeg

{...}


procedure TForm1.SaveClipboardToJPEG(Sender: TObject);
var
  Jpeg1: TJpegImage;
begin
 if Clipboard.HasFormat(CF_BITMAP) then
 begin
   Jpeg1:=TJpegImage.Create;
   Jpeg1.Assign(Clipboard);
   Jpeg1.CompressionQuality:=75;  //quality for compressing 1..100
   Jpeg1.Compress;
   Jpeg1.SvaeToFile('Clipboard.jpg');
 end;
end;
0

Featured Post

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.

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now