CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    33

    Reading Images in a Canvas-derived Class

    Hi !
    I have coded an applet which uses a derived-from-Canvas class to
    do some graphics. Now I want to load an iamge from disk, but

    getImage(getCodeBase(),"mypix.jpg");



    doesn't work cause there is no codebase. How can I implement
    that ?

    cya
    Skippy


  2. #2
    Join Date
    Dec 1999
    Location
    Chonghe, Taipei County, Taiwan, R.O.C.
    Posts
    231

    Re: Reading Images in a Canvas-derived Class

    getImage is the method of the class Applet. Hence, you can not call this method in the subclass of
    Canvas. You should get this image by the method getImage() which is called in the init() method of
    the applet. And put the image object that you get via the getImage() method to the subclass of Canvas
    for painting. You may set the image to the subclass of Canvas and draw this image in the method
    paint() which override the same method in the Canvas.
    good luck,
    Alfred Wu


  3. #3
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    33

    Re: Reading Images in a Canvas-derived Class

    Hi ,
    and thanks for the answer. This was the only possibility I had in mind, too. Hence the applet
    is not my part in this project, I have to set up a function in my subclass, i.e

    void setMyImage(Image myImg){blah}



    to get the Image into my subclass, right?
    Ok, even better than hardcoding all the Images
    pixel by pixel...

    cu
    Skippy



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured