Solved

JPEG Images

Posted on 1998-12-11
16
444 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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
 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…

777 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