Solved

JPEG Images

Posted on 1998-12-11
16
445 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 Photo Editor that works on Domains 4 94
PhotoSHop text banner 2 77
Reconfigure Delphi Install? 2 61
delphi popmenu non latine charcters 3 13
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It’s easy to embed any of your public Prezi presentations on your website or social network to share with others. Learn how simple it is in this tutorial.
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…

830 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