load image using library ...

Posted on 2004-11-25
Last Modified: 2013-11-17
Hi Experts,

    I am trying to load some jpeg files using some library. I tried the following code, it is compiled fine, however, I saw no images ? Does anyone know what I might have missed ??? many thanks !!!

#include <vcl.h>
#include <iostream.h>

#include "EColor.h"
#include "EImage.h"

#pragma hdrstop

#pragma argsused
int main(int argc, char* argv[])
    EImageC24 EC24Image1;  // EImageC24 class instance
    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

//  This section contains the operations code
// 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);
// Load BGA Substrate Color.jpg image into EC24Image4
eFileFormat = EC24Image4.Load("C:\\Program Files\\Euresys\\eVision\\Images\\EasyColor\\BGA Substrate Color.jpg");

        cout << " Test " << endl ;
         getchar() ;
        return 0;
Question by:meow00
    LVL 4

    Expert Comment

    Without knowing the specific library you are using it is hard to know what you are supposed to be doing exactly.  However seeing that this is a console application (I think) I am guessing that just calling .LoadImage() is simply loading the image file into memory and is not physically displaying it, you will need to call a separate member function for EImageC24 in order to actually display the image on the screen.

    *** Insert Google search here ***

    I am guessing that you are using the eVision C++ library.  There is a separate draw function that is required to be called (as far as I can tell from a quick look) in order to display the image.  The function also needs to be passed in a window handle of the window that will display the image.  In order to pass in a Windows handle, you will need to start a Windows application rather than a simple console application which I think you may be using at the moment
    LVL 1

    Author Comment

    Thanks very much ! What you guess is close to what I need to do.
    So could you please give me some suggestions :
    What kind of application should I use ? frame ? or form ? or just use :
    File -> New -> Application ???

    many thanks !!!

    LVL 4

    Expert Comment

    File | New | Application from within C++ Builder will give you a base for a Windows application / project and will also present you with a main form on which you can place your image.

    If using a TForm to display the image, you will not need to use the eVision library (if tat is what you are using) unless you need the funcionality that it provides.  If you are just simply trying to display an image on a TForm:

    Create a new project (File | New | Application)
    Add a TImage component to the form within the IDE at design time and double click the added TImage component to allow you to load an image for display.
    Once the image has been selected and loaded, you can set the AutoSize property of the Image component to be true so that the whole image can be viewed.

    LVL 1

    Author Comment

    Thanks very much ! I do need some functions from eVision library in the future .....

    so ... could you please where the "TImage" locates ? I couldn't find it at all :-(

    many thanks !
    LVL 4

    Accepted Solution

    If you need functions from the eVision library then you may not be able to use TImage class and retain functionality of the eVision library.

    To use the EImageC24 class, you can call the Draw function and simply pass in the device context of the window control where you wish to draw the image.

    Within the TForm, you can possibly do something like:


    and see what happens.  I have never used C++ Builder to draw directly to a device context so am not sure what the results will be if drawing directly to the DC of the TForm.  You may need to add a TFrame to the main TForm and then draw to the frame's DC instead.

    (from within the TForm's OnShow event or similar)


    NOTE: This code may not work as I am not using the eVision library and have not used DC's directly as mentioned above.  But then again - it just might work.

    LVL 1

    Author Comment

    Thanks very much .... I will work on it  ^^

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    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. …
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now