Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Printing JPGs

Posted on 1998-07-31
4
Medium Priority
?
258 Views
Last Modified: 2013-11-19
Hello...
I have to print a document which includes a picture. To save physical space I decided to use .JPG - Files everywhere instead of BitMaps. But when I'm trying to print a such JPG, i get exception with 'Graphic Format is not valid', but I made sure, that the JPEG-Unit (Delphi 3, prof) is loaded. It would be good if I could use JPGs, because the BMP File Size is about 240KB while the JPG is only 32KB. Please note, I'm only a young student, so I hope there is a way to get around this without the need of an expensive component.

Another Question is, is there a command like <Center> in HTML to Center Text/Images or do I have to mess with the Pixels ?

here the used code (in short version)

procedure TForm43.BitBtn3Click(Sender: TObject);

var
  BitMap : TBitMap;

begin
  if Printer.Printing then
    Application.MessageBox('Printer is actually busy', 'CompQuiz Print Error', 0)
  else
    begin
      Printer.Title := 'CompQuiz Statistics';
      Printer.BeginDoc;
      with Printer.Canvas do
        begin
          Font.Name := 'Arial';
          Font.Pitch := fpDefault;
          Font.Style := [fsItalic, fsBold];
          Font.Size := 30;
          Font.Color := clBlue; //my printer ran out of black cartridge
          TextOut(100, 100, 'Omsec CompQuiz32 v1.0 ALPHA');
          BitMap := TBitMap.Create;
          BitMap.LoadFromFile('c:\quiz\gb.jpg');
          Draw(100, 300, BitMap);
          BitMap.Free;
        end;
      Printer.EndDoc;
    end;
end;

Thanx for Help :)
0
Comment
Question by:omsec
[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
  • 2
4 Comments
 
LVL 2

Author Comment

by:omsec
ID: 1359302
btw, when I used "c:\quiz\gb2.bmp", same as the JPG instead it worked fine.
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 280 total points
ID: 1359303
omsec

replace this

var
      BitMap : TBitMap;

with this

var
    JPG: TJpgImage;

and this

          BitMap := TBitMap.Create;
              BitMap.LoadFromFile('c:\quiz\gb.jpg');

with this...

          JPG := TJpgImage.Create;
              JPG.LoadFromFile('c:\quiz\gb.jpg');

and finally this...

          Draw(100, 300, BitMap);
              BitMap.Free;

with this...

          Draw(100, 300, JPG);
              JPG.Free;

this should do it...

Later
BoRiS  
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1359304
omsec

sorry it should be

var
 JPG : TJpegImage;

not TJpgImage;

and

JPG := TJpegImage.Create;

not JPG := TJpgImage.Create;

Later
BoRiS
0
 
LVL 2

Expert Comment

by:kjteng
ID: 1359305
For your infomation, there are some FREEware for reading JPG file in the web. eg.

NViewlib.dll at http://einstein.ae.eng.ua.edu/nishita/index.htm 
is a dll that enable you to manupulate JPG, JIF, GIF, BMP, DIB, RLE, TGA, PCX.

Jpegimage at  WWW: http://www.westend.de/~hoerstemeier

checkout delphi super page for more.

Sound like advertisement? I have no dealing with the authors of these software or webpage :-))
0

Featured Post

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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Suggested Courses

609 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