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

x
?
Solved

Using TJPEGImage from Borland

Posted on 1998-09-30
5
Medium Priority
?
2,040 Views
Last Modified: 2012-05-04
I am using TJPEGImage from Borland (VCL, C++Builder3)

I am having a lot of problems using LoadFromStream. It seems that the Image contents is updated but the image does not get repainted (updated) on the screen !?

Anyone out there that have seen this ?

I will increase the points appropriately if anyone here can help me, otherwise I will try in the Delphi Group ...

I modified their example as follows duplicating my problem :

void __fastcall TForm1::OpenFile(const AnsiString Filename){
        TStream *MyStream;  // Added a stream
      try{
        MyStream = new TFileStream(Filename,fmOpenRead | fmShareDenyNone);  // Use a file stream in stead of LoadFromFile
//            Image1->Picture->LoadFromFile(Filename); // Removed the borland load method
        if (Image1->Picture->Graphic == NULL) { // Create if not existing
// I would also like this built into LoadFromStream on TPicture !
          Image1->Picture->Graphic = new TJPEGImage;

        }
        Image1->Picture->Graphic->LoadFromStream(MyStream);
        delete (TFileStream *)MyStream;
      } catch(EInvalidGraphic &x){
            Image1->Picture->Graphic = NULL;
      }
      SetJPEGOptions(this);
}
0
Comment
Question by:gysbert1
[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
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:WxW
ID: 1174059
I recommend ( although I use Borland too ) to use the K.Nishitas freeware image converter library .
http://einstein.ae.eng.ua.edu/nishita/index.htm

Last time it was shutdown ... if you want I will mail the dll to you . It takes a simple image file and returns a HBITMAP to use.
0
 
LVL 2

Author Comment

by:gysbert1
ID: 1174060
Two things.

1) Is it freeware or will it cost me ?
2) I like the Borland approach to hook into TGraphic. It is the way that images were designed to work and will most likely be the best optimized (display wise). Do I have to Hook into a paint somewhere and do a stretchdraw with that library ? If I do that with the Borland library it works fine but I do not want to go that way if at all possible.


0
 
LVL 6

Expert Comment

by:WxW
ID: 1174061
It is FREE , BUT
the only useful thing is that you read a JPG or other image from a file , and you convert it to a HBITMAP . Also  , you can save a HBITMAP to a JPG file .
0
 
LVL 2

Author Comment

by:gysbert1
ID: 1174062
Ok, I have solved the problem !

I did the unspeakable and changed the Borland code. Their code frees the HBitmap associated with the TJPEGImage when you LoadFromFile. It does not do this whe loading from a stream however. Also, as an optimisation, they do not decompress the JPEG if the bitmap exists, assuming it matches the JPEG data.

I added a line that frees the FBitmap in the TJPEGImage when loading from a stream. The first time that the bitmap is needed it gets created with the new data as it should.

This  looks like a bug on borland's side to me, I will post here if I hear anything from them in future.

WxW, you can have the points for this one. Then you get paid for trying and others can learn from my woes ...

:o(
0
 
LVL 6

Accepted Solution

by:
WxW earned 40 total points
ID: 1174063
Thanks:)
0

Featured Post

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.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

618 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