Solved

JPEG Images

Posted on 1998-12-11
16
439 Views
Last Modified: 2013-11-19
I think this may be a little known fact...but hidden on the Delphi 3 CD ROM is a folder called INFO.  Inside of the INFO folder is another folder called EXTRAS.  Inside of EXTRAS is a folder called JPEG.

The JPEG folder is pretty cool.  It has files you can install that allow you to use a TImage component to view JPEG images.  JPEG images have a compression algorithm which allows them to take up a lot less space than an equivalent .BMP image.

I installed JPEG support into my copy of Delphi 3...and sure enough...now I can view JPEGS in Delphi 3.  I was pretty excited.

But now, I can't utilize any of the other methods that make TImage so cool.  For example...when I try to draw a Focus Rect on the JPEG image...the program crashes / give me an error message:

EInvalidOperation:  Can only modify an image if it contains a bitmap

Can someone help me figure out what to do?  It seems silly to allow TImage to load JPEG images...but then you can't do anything with them.

If I load a bitmap instead of a JPEG...I can use all of the methods of  TImage with no problems.

Thanks.
0
Comment
Question by:knowlton
  • 9
  • 5
  • 2
16 Comments
 
LVL 5

Author Comment

by:knowlton
ID: 1350622
Edited text of question
0
 
LVL 5

Author Comment

by:knowlton
ID: 1350623
Edited text of question
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1350624
Hi

My understanding of Delphi's JPegs is that they don't have a published canvas to work with.  I have overcome this problem before by using "dummy" bitmaps as follows:

Bmp := TBitmap.Create;
Bmp.Assign(MyJPeg);
// Do stuff with the Bmp...
MyJPeg.Assign(Bmp);
Bmp.Free;

A bit clumsy, but it works.

Cheers,
JB
0
 
LVL 5

Author Comment

by:knowlton
ID: 1350625
Edited text of question
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1350626
JimBob is right...

btw- KnowIton, what's up with your Sprites Editror (or was it Game Editor)?? Anyway, did you get it done??

Cheers,
Viktor
0
 
LVL 5

Author Comment

by:knowlton
ID: 1350627
JimBob:

I will be giving you your points here shortly...as soon as I have a chance to try it out and get it working.  Sounds like you know what you'r talking about.

Viktornet:

Hey, my friend!  Good to hear from you!  The Gargor Map Editor is ON HOLD for the moment.  I haven't done anything with it for 3 or 4 months now.  I still have all the source code for it and have every intention of working on it again some day...but don't hold your breath.

BUT, I do have another project I'm working on which is a MYST type game.  There is another person helping me with it (a co-worker, actually).  He is doing all of the art in POV-Ray and it looks really nice.  He's also able to make some fine-looking AVI movies as well so we'll have some nice intros and cut scenes.  If you want to help with the project just let me know.
0
 
LVL 5

Author Comment

by:knowlton
ID: 1350628
JimBob:

Go ahead and resubmit your comment as an answer. Thanks for your help.

Tom
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1350629
Hello Tom!

NIce to hear from also :)

I haven't had much time to work with Delphi lately, but if oyu need specific help, I might try and help you. I'd also really like to see what you've done so far... What actually is the MYST kinda game??? I have no idea what that is.. 10Q

Cheers,
Viktor
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 5

Accepted Solution

by:
JimBob091197 earned 30 total points
ID: 1350630
Hi knowlton, glad to be of help.
Cheers,
Dave

0
 
LVL 5

Author Comment

by:knowlton
ID: 1350631
JimBob:

Here are your points.  

BUT:  It's not working correctly.  There is some subtlety of this process I'm haven't figured out.

The JPEG is being assigned to a TImage component I have already dropped on the form.  But the TBitmap is being created from scratch.  And...how do I draw on the TBitmap?  I can assign the JPEG image to the TBitmap...just like you said....but I can't do anything with the TBitmap.

Please help me.
0
 
LVL 5

Author Comment

by:knowlton
ID: 1350632
Viktornet:

MYST is a point-and-click type game which concentrates more on visually stunning still pictures and puzzles.  There is this immense 3D world you can fully explore.  Pretty cool.  

JimBob is not getting back to me yet.  Can you provide any help with TBitmap and TImage?
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1350633
Hi knowlton

Sorry about the delay - I don't have 24-hr online internet access!!  ;-)

You can draw on a bitmap's canvas:
  MyBmp.Canvas.MoveTo(0, 0);
  MyBmp.Canvas.LineTo(100, 100);
  etc...

Then assign it back to the JPEG.

Does this help you?

Dave
0
 
LVL 5

Author Comment

by:knowlton
ID: 1350634
I will try this as soon as I can.

Does the bitmap get assigned to a TImage as well?
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1350635
From what I recall (I'm not at my Delphi PC) you assign the bmp to TImage.Picture:

MyImg.Picture.Assign(MyBmp);

Cheers,
Dave

0
 
LVL 5

Author Comment

by:knowlton
ID: 1350636
The IS working now.  Thanks so much.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1350637
No prob.
 -Dave
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
Learn how to create interesting presentations by including videos to keep your audience engaged using Prezi. Select "Insert" from the top menu in your Prezi editor: Select "YouTube Video": Paste the video URL into the prompt: "Select "Insert":…

707 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

18 Experts available now in Live!

Get 1:1 Help Now