Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

JPEG Images

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
Tom Knowlton
Asked:
Tom Knowlton
  • 9
  • 5
  • 2
1 Solution
 
Tom KnowltonWeb developerAuthor Commented:
Edited text of question
0
 
Tom KnowltonWeb developerAuthor Commented:
Edited text of question
0
 
JimBob091197Commented:
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
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
Tom KnowltonWeb developerAuthor Commented:
Edited text of question
0
 
viktornetCommented:
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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
JimBob:

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

Tom
0
 
viktornetCommented:
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
 
JimBob091197Commented:
Hi knowlton, glad to be of help.
Cheers,
Dave

0
 
Tom KnowltonWeb developerAuthor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
JimBob091197Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
I will try this as soon as I can.

Does the bitmap get assigned to a TImage as well?
0
 
JimBob091197Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
The IS working now.  Thanks so much.
0
 
JimBob091197Commented:
No prob.
 -Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 9
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now