?
Solved

load an image (using a library) to a form ...

Posted on 2004-11-25
7
Medium Priority
?
819 Views
Last Modified: 2013-11-17
Hi experts,

   This is a follow up question of :
 http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus_Builder/Q_21219873.html

   Now I am trying to load an image using some library (Yes, I need to use some functions of the library later ...). The following code compiled but I see no image ......
 
  Here is the Draw function :
 void Draw(HDC hDC, FLOAT32 f32ZoomX = 1.f, FLOAT32 f32ZoomY = 0.f) ;

  Therefore, how do I modify line00 ? or how to add any device context in the following code  in order to solve the problem ??? Please help ! many thanks !!!

meow.
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"

#include "EColor.h"  //EasyColor Header
#include "EImage.h"  //EasyImage Header

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
   EImageC24 EC24Image1;

   enum IMAGE_FILE_TYPES eFileFormat;   // File type for load and save of images
   EColorLookup EColorLookup1;  // EColorLookup class instance
   EImageC24 EC24Image2;  // EImageC24 class instance
   EColorLookup EColorLookup2;  // EColorLookup class instance
   EImageBW8 EBW8Image3;  // EImageBW8 class instance
   EImageC24 EC24Image4;  // EImageC24 class instance
   EColorLookup EColorLookup3;  // EColorLookup class instance

   EC24Image1.Draw(this->GetDeviceContext);  // line00 .............

  //  This section contains the operations code
   ESetJpegQuality(90);
   // Load BGA Substrate Color.jpg image into EC24Image1
   eFileFormat = EC24Image1.Load("C:\\Program Files\\Euresys\\eVision\\Images\\EasyColor\\BGA Substrate Color.jpg");
// Load BGA Substrate Color.jpg image into EC24Image2
   eFileFormat = EC24Image2.Load("C:\\Program Files\\Euresys\\eVision\\Images\\EasyColor\\BGA Substrate Color.jpg");
   EBW8Image3.SetSize(512, 512);
   EBW8Image3.SetSize(&EC24Image2);
// Load BGA Substrate Color.jpg image into EC24Image4
eFileFormat = EC24Image4.Load("C:\\Program Files\\Euresys\\eVision\\Images\\EasyColor\\BGA Substrate Color.jpg");

}
//---------------------------------------------------------------------------
0
Comment
Question by:meow00
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:Woodster
ID: 12678092
Try using the HDC of the Canvas property within the TForm.

EC24Image1.Draw(this->Canvas->Handle);
0
 
LVL 4

Expert Comment

by:Woodster
ID: 12678117
That line above will pass in the device context of the TForm.Canvas which is what the TForm component uses to draw itself on.  Let me know if you have more luck with that.
0
 
LVL 1

Author Comment

by:meow00
ID: 12678120
Thanks a lot .... but why I got the following errors by replacing line00 with the above line ??? please help. thanks !

[Linker Error] Unresolved external 'EImage<EC24>::Draw(void *, float, float)' referenced from C:\DOCUMENTS AND SETTINGS\TEST\UNIT1.OBJ
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Woodster
ID: 12678165
A linker error such as that means that the function EImage<EC24>::Draw(void *, float, float) has not been found in the list of .lib / .obj files that are being linked in to the executable.  If the application was successfully compiling and linking previously when you had the previous call to draw in then it should still link now.

You may need to check the library documentation and make sure you have included any required .lib or .obj files in your project so that they can be linked at compile time.

Try this and see if it compiles and links

HDC deviceContext = this->Canvas->Handle;
EC24Image1.Draw(this->Canvas->Handle);
0
 
LVL 1

Author Comment

by:meow00
ID: 12678220
Thanks very much ... I tried View | Project Manager to view all files in the project. I did see all the required .lib there ... however, I still have the same errors ... what else could possiblely be a problem ??? many thanks !

0
 
LVL 4

Accepted Solution

by:
Woodster earned 1200 total points
ID: 12678279
Without having the library here to play wround with I am clutching at straws a little and you may need to try a bit of trial and error.  Firstly, am I correct in thinking that the original code you posted above compiled and linked?

(All the following in place of line00)

Does this compile and link:

EC24Image1.Draw(this->GetDeviceContext(this));

Does this compile and link:

HDC deviceContext = this->Canvas->Handle;
EC24Image1.Draw(this->Canvas->Handle);

Does this compile and link:

HDC deviceContext = this->GetDeviceContext(this);
EC24Image1.Draw(this->Canvas->Handle);
0
 
LVL 1

Author Comment

by:meow00
ID: 12678382
All the three cases above didn't compile and link. They all have the same errors as I mentioned before. I guess I will double check the lib and functions ......

many thanks !!!

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

864 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