Drawing images when your class is in a package.

I have a class in a package. The image I want to draw is in the package, but when I draw it g.drawImage(img, 0, 0, this); it won't draw, even though the image is in the same directory as that class.
Here is the code:
package Game;
import java.awt.*;
public class SplashScreen extends Frame{
     splashPanel sp;
     public SplashScreen(){
          super("Splash");
          sp = new splashPanel();
          add(sp);               
class splashPanel extends Panel{
     Image splash;
     public splashPanel(){
          super();
          splash = Toolkit.getDefaultToolkit().getImage("paddle1.gif");
          repaint();          
     public void paint(Graphics g){
          g.setColor(Color.black);
          g.fillRect(0,0,200,200);
          g.drawImage(splash, 0, 0, this);
          System.out.println("Image");
}

Still doesn't work.
package Game;
import java.awt.*;
public class SplashScreen extends Frame{
     splashPanel sp;
     public SplashScreen(){
          super("Splash");
          sp = new splashPanel();
          add(sp);               
class splashPanel extends Panel{
     Image splash;
     public splashPanel(){
          super();
          splash = Toolkit.getDefaultToolkit().getImage("splash.jpg");
          MediaTracker tracker = new MediaTracker(this);
          tracker.addImage(splash, 0);
          try{
               tracker.waitForID(0);
          } catch (InterruptedException e){}
          repaint();          
     public void paint(Graphics g){
          g.setColor(Color.black);
          g.fillRect(0,0,200,200);
          g.drawImage(splash, 0, 0, this);
          System.out.println("Image");
}

Similar Messages

  • Problems drawing images form another class

    Ok as the title says I'm having trouble drawing images from a different class. I have a class that represents a plane and it has a draw' method that draws its .gif image.
    public void draw (Graphics g)
    g.drawImage(planepic , xPos, yPos, null)
    then in my main class in the paint method i have
    plane.draw(g);
    I think my problem is the null for my image observer. I tried using null as my image observer and i got a error saying i can't make a static reference to a non static method.
    I've done some research because i never really understood static but i still don't quite get it.
    Also when I use this as my image observer i get a error in my plane object.
    I also just tried passing and making a object for my main class and i still got the static error.
    Any help is appreciated and thanks in advance

    Ok as the title says I'm having trouble drawing
    images from a different class. I have a class that
    represents a plane and it has a draw' method that
    draws its .gif image.
    public void draw (Graphics g)
    g.drawImage(planepic , xPos, yPos, null)
    in my main class in the paint method i have
    plane.draw(g);
    I think my problem is the null for my image observer.
    I tried using null as my image observer and i got a
    error saying i can't make a static reference to a non
    static method. Use a minimal implementation of the ImageObserver to be sure.
    public class Plane implements ImageObserver
    public boolean imageUpdate(
    Image img,int infoFlags,int x,int y,int width,int height)
       switch(infoFlags)
          case ALLBITS:
                    return false;
          case SOMEBITS:
                    return true;
          default:
                return true;
    I've done some research because i never really
    understood static but i still don't quite get it.
    Also when I use this as my image observer i get a
    error in my plane object.
    I also just tried passing and making a object for my
    main class and i still got the static error.
    Any help is appreciated and thanks in advanceWhen you call draw(g) from your other class you hand it a Graphics context that you instantiated somewhere else ie: in another class. Without a more complete example it is really impossible to determine your issue for sure,
    but if I was to guess I would say you need to make sure that the Graphics context handed to the draw(Graphics) method was instantiated from a Component that was already visible. ie: Do a f
    Frame.createImage() from your parent frame after iyou have already called setVisible(true); In other words I suspect you are making and Image from some other Component that is not yet visible. That however is a guess so if not the issue post the rest of the code or at least a minimal implementation that demonstrates this.
    About static:
    static means the class/variable is the same throughout ALL classes of that type and if changed in one instance it will change and thus be the same for all instances.
    You CAN call static by referencing the base class Object without having to instantiate.
    ie:given
    public class SomeClass
    static String name;
    static String getName
       if(name == null)
          name = "DefaultName";
       return name;
    }Thus you could call..
      String name = SomeClass.getName();As opposed to
    SomeClass myClass = new SomeClass();
          myClass.getName();This can get you in trouble if you try to make a method that is static
    that then tries to reference non static variables.
    ie:
    public class SomeClass
    int x;
    static String name;
    SomeClass()
       x=0;
    static String getName
       if(name == null)
          name = "DefaultName";
       x++;
       return name;
    }In this case SomeClass.getName(); will throw and exception because it is trying to access[b] x  from a static context .
    Hope that clears that up for you; if not post a more complete example.
    Good Luck!
    (T)

  • How to comunicate two class in the same package

    I HAVE SET MY CLASSPATH as /home/shadab/program/java/MyPack in CLASSPATH environment variable.
    below is a super class java file Protection.java
    I also compiled it successfully using javac Protection.java
    package MyPack;
    public class Protection {
    int n = 1;
    private int n_pri = 2;
    protected int n_pro = 3;
    public int n_pub = 4;
    public Protection() {
    System.out.println("base constructor ");
    System.out.println("n = " + n);
    System.out.println("n_pri = " + n_pri);
    System.out.println("n_pro = " + n_pro);
    System.out.println("n_pub = " + n_pub);
    Below is subclass of superclass
    package Mypack;
    class Derived extends Protection {
    Derived() {
    System.out.println("Derived constructor ");
    System.out.println("n = " +n);
    // System.out.println("n_pri = " + n_pri);
    System.out.println("n_pro = " + n_pro);
    System.out.println("n_pub = " + n_pub);
    while i compiled subclass
    javac Derived.java
    following error occured
    Derived.java:3: cannot find symbol
    symbol: class Protection
    class Derived extends Protection {
    ^
    Derived.java:8: cannot find symbol
    symbol : variable n
    location: class Mypack.Derived
    System.out.println("n = " +n);
    ^
    Derived.java:11: cannot find symbol
    symbol : variable n_pro
    location: class Mypack.Derived
    System.out.println("n_pro = " + n_pro);
    ^
    Derived.java:12: cannot find symbol
    symbol : variable n_pub
    location: class Mypack.Derived
    System.out.println("n_pub = " + n_pub);
    PLEASE HELP ME TO SOLVE THIS PROBLEM ..

    1. To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
    2. Read this page:
    [http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html]
    3. I advise that you don't use the CLASSPATH environment variable. Instead, use the -classpath or -cp flag when compiling/running.
    4. The package root must be available on the classpath. Since your classes are in the package MyPack and in the folder /home/shadab/program/java/MyPack, that means that /home/shadab/program/java must be on the classpath.
    db

  • How to set images to your contacts to see their picture when there calling? Like their facebook picture.

    How to set images to your contacts to see thier picture when someone is calling? Like for instance facebook picture.(on the iPHONE 4s)

    You can manually add a photo to each contact on your iPhone - from an existing photo of the contact on your iPhone or capture a photo of the contact when together. Or add a photo for each contact in the address book app on your computer that is supported for syncing contacts with the iPhone followed by a sync.
    For FaceBook check this link, which I found with a Google search.
    http://www.iphonestuffs4u.com/how-to-sync-facebook-contacts-to-iphone/

  • When I try to print my book I receive the following error message:  One or more of the images in your book are not presently available at full resolution. Please reconnect to these files by mounting the volume(s) containing the original images.

    When I try to print my book, I receive the following error message:  One or more of the images in your book are not presently available at full resolution. Please reconnect to these files by mounting the volume(s) containing the original images.  I don't understand what this means since all the photos are in the book.  Can someone please clarify?

    When you look at the images in the browser, do you see any arrow icons on your thumbnails? Like these:
    When you import your images from a folder on your system drive, you have two ways to import:
    Managed: Import and store the images in the library
    Or referenced: Leave the images in the folder outside the Aperture library.
    This is controlled by the "Store Files" settings in the Import panel:
    If you did not set "Store files" to "In the Aperture Library", the originals will stay in the folder outside.
    The error message you get, suggests that Aperture assumes the original files are in a folder outside the library.
    Select one of your images in the Browser and use the command "File > Show in Finder" - is this command available or dimmed out?

  • Drawing images in JComponent

    Hi,
    I have an application laid out as Figure 1 depicts.
    JFrame
    |
    | JMenuBar
    |-----------------------------------------
    | ------------------JPanel - appPanel
    | |--------------------------------|
    | | ---|------------------ JPanel - displayPanel
    | | | |
    | |----------------|---------------|
    | |-------------------------- JComponent - jcanvas
    |
    | |--------------------------------|
    | | ----|----------------------- JPanel - controlPanel
    | | |
    | |--------------------------------|
    |
    |--------------------------------------------
    Figure 1
    The problem I am having is that:
    theJPanel (appPanel) contains two JPanels (displayPanel and controlPanel) and I am adding a JComponent called JCanvas
    to the displayPanel and I use it to draw images on it of type BufferedImage. Now, the image is displayed without any problem
    but when I resize the application (JFrame) I lose my image. I know the JCanvas (JComponent) is being redrawn because I can
    temporarily see the image but something is overwriting the image. I have set appPanel, displayPanel, controlPanel to opaque
    but I still loose the image.
    Of point maybe, if I access the JMenuBar the image will appear less what part of the menu bar obscures it.
    The appPanel, controlPanel, and displayPanel are created in the IDE. Where as, the JCanvas is a seperate class extending JCompoment
    and it has it own paintComponent method to do the image rendering and is added to the displayPanel when instantiated.
    What I don't understand is why isn't the image staying visible after a frame resize?
    Thanks,
    Bob

    Hopefully this will fit.
    You will have to provide your own image file.
    * SwingPaintDemo2.java
    * Created on Sep 27, 2008, 10:57:22 AM
    * Company: 
    * Copyright: Sep 27, 2008
    * Version:
    import javax.swing.SwingUtilities;
    import javax.swing.JFrame;
    import javax.swing.BorderFactory;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.imageio.ImageIO;
    import javax.swing.JComponent;
    * @author
    public class SwingPaintDemo2 {
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
        private static void createAndShowGUI() {
            System.out.println("Created GUI on EDT? " +
                SwingUtilities.isEventDispatchThread());
            JFrame f = new JFrame("Swing Paint Demo");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new MyPanel());
            f.pack();
            f.setVisible(true);
    class MyPanel extends JComponent {
        BufferedImage bi;
        File file;
        Dimension d = new Dimension();
        boolean fullScreen = false;
        public MyPanel() {
            setBorder(BorderFactory.createLineBorder(Color.black));
            file = new File("g://java/images/dido_img.jpg");
            try {
                bi = ImageIO.read(file);
            } catch (IOException ex) {
                Logger.getLogger(MyPanel.class.getName()).
                    log(Level.SEVERE, null, ex);
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(350, 350);
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) this.getGraphics();
            d = this.getPreferredSize();
            if (d.width == 0 || d.height == 0) {/* error */
            if (!fullScreen) {
                int px = (d.width - bi.getWidth()) / 2;
                int py = (d.height - bi.getHeight()) / 2;
                g2.drawImage(bi, null, px, py);
            } else {
                g2.drawImage(bi, 0, 0, d.width, d.height,
                    0, 0, bi.getWidth(), bi.getHeight(), null);
    }

  • How to stop drawing image

    I have an image issue from an url, and I would like create a button giving user posibility of stopping loading and drawing the image in a canvas.
    But how to stop paint method in the canvas ??

    I am not sure whether this will work for you, but give it a try.
    Create a boolean flag say, stopPaint. Set it to false to start with, and when you want the canvas to stop painting, set it true. In your class that extends Canvas, override the imageUpdate() method. Here is an example:
      public boolean imageUpdate(Image img,
                                 int infoflags,
                                 int x,
                                 int y,
                                 int width,
                                 int height){
          if(stopPaint) {
             stopPaint = false;
             return false;
           if((infoflags & ImageObserver.ERROR) != 0){
              System.out.println("ERROR in image loading or drawing");
              return false;
           if((infoflags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS))!= 0) {
              //Image loaded
              //code to paint the image;
              repaint();
              return false;
           return true;
       }When an image is being loaded or drawn, the imageUpdate() method is called at regular intervals.
    When the imageUpdate() method returns false, there won't be any more updates, i.e., imageUpdate() won't be called again. Make sure to put your painting code in an appropriate place.
    Note that this will not work if your use Java 2D or JAI APIs to load images. Only the AWT imaging loads the image asynchronously. In other words, use the getImage() method (of Applet or Toolkit).

  • How can I draw image in a vbean?

    How can I draw image in a vbean?
    this is my code :
    import java.awt.BorderLayout;
    import java.awt.Image;
    import java.awt.Graphics;
    import java.net.MalformedURLException;
    import java.net.URL;
    import com.sun.jimi.core.Jimi;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.VBean;
    public class PrintEmailLogo extends VBean {
         URL url;
         Image img;
         boolean ImageLoaded = false;
         public void paint(Graphics g) {
              if (ImageLoaded) {
                   System.out.println("yes~~~");
                   g.drawImage(img, 0, 0, null);
              } else
                   System.out.println("no~~~");
         public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
                   int h) {
              if (infoflags == ALLBITS) {
                   System.out.println("yes");
                   ImageLoaded = true;
                   repaint();
                   return false;
              } else
                   return true;
         public void init(IHandler arg0) {
              super.init(arg0);
              try {
                   url = new URL("file:print/77G.gif");
                   img = Jimi.getImage(url);
                   Image offScreenImage = createImage(size().width, size().height);
                   Graphics offScreenGC = offScreenImage.getGraphics();
                   System.out.println(offScreenGC.drawImage(img, 0, 0, this));
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    but when I run it in forms
    when it run Graphics offScreenGC = offScreenImage.getGraphics();
    It throw a exception:
    java.lang.NullPointerException     at com.avicit.aepcs.calendar.PrintEmailLogo.init(PrintEmailLogo.java:72)     at oracle.forms.handler.UICommon.instantiate(Unknown Source)     at oracle.forms.handler.UICommon.onCreate(Unknown Source)     at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)     at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)     at oracle.forms.engine.Runform.processMessage(Unknown Source)     at oracle.forms.engine.Runform.processSet(Unknown Source)     at oracle.forms.engine.Runform.onMessageReal(Unknown Source)     at oracle.forms.engine.Runform.onMessage(Unknown Source)     at oracle.forms.engine.Runform.processEventEnd(Unknown Source)     at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)     at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)     at java.awt.Component.dispatchEventImpl(Unknown Source)     at java.awt.Container.dispatchEventImpl(Unknown Source)     at java.awt.Component.dispatchEvent(Unknown Source)     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)     at java.awt.Container.dispatchEventImpl(Unknown Source)     at java.awt.Component.dispatchEvent(Unknown Source)     at java.awt.EventQueue.dispatchEvent(Unknown Source)     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)     at java.awt.EventDispatchThread.run(Unknown Source)
    I change it to:
    import java.awt.BorderLayout;
    import java.awt.Image;
    import java.awt.Graphics;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.swing.JFrame;
    import com.sun.jimi.core.Jimi;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.VBean;
    public class PrintEmailLogo extends VBean {
         URL url;
         Image img;
         public void paint(Graphics g) {
              try {
                   url = new URL("file:print/77G.gif");
                   img = Jimi.getImage(url);
                   g.drawImage(img, 0, 0, this));
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public void init(IHandler arg0) {
              super.init(arg0);
    But it display nothing.
    It isn't paint continuous.
    what's wrong in my vbean?
    please help me.

    The following code works fine for me:
    package oracle.forms.fd;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.CustomEvent;
    import oracle.forms.ui.VBean;
    public class test extends VBean {
      private URL url;
      private URL m_codeBase; 
      private Image img;
    public void paint(Graphics g) {
      // draw the image
      g.drawImage(img, 0, 0, this);
    public void init(IHandler arg0) {
       super.init(arg0);
       // load image file
       img = loadImage("file:///c:/coyote.jpg");   
    public test()
        super();
       *  Load an image from JAR file, Client machine or Internet URL  *
      private Image loadImage(String imageName)
        URL imageURL = null;
        boolean loadSuccess = false;
        Image img = null ;
        //JAR
        imageURL = getClass().getResource(imageName);
        if (imageURL != null)
          try
            img = Toolkit.getDefaultToolkit().getImage(imageURL);
            loadSuccess = true;
            return img ;
          catch (Exception ilex)
            System.out.println("Error loading image from JAR: " + ilex.toString());
        else
          System.out.println("Unable to find " + imageName + " in JAR");
        //DOCBASE
        if (loadSuccess == false)
          System.out.println("Searching docbase for " + imageName);
          try
            if (imageName.toLowerCase().startsWith("http://")||imageName.toLowerCase().startsWith("https://"))
              imageURL = new URL(imageName);
            else if(imageName.toLowerCase().startsWith("file:"))
              imageURL = new URL(imageName);
            else
              imageURL = new URL(m_codeBase.getProtocol() + "://" + m_codeBase.getHost() + ":" + m_codeBase.getPort() + imageName);
            System.out.println("Constructed URL: " + imageURL.toString());
            try
              img = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              System.out.println("Image found: " + imageURL.toString());
              return img ;
            catch (Exception ilex)
              System.out.println("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            System.out.println("Error creating URL - " + urlex.toString());
        //CODEBASE
        if (loadSuccess == false)
          System.out.println("Searching codebase for " + imageName);
          try
            imageURL = new URL(m_codeBase, imageName);
            System.out.println("Constructed URL: " + imageURL.toString());
            try
              img = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              System.out.println("Image found: " + imageURL.toString());
              return img ;
            catch (Exception ilex)
                    System.out.println("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            System.out.println("Error creating URL - " + urlex.toString());
        if (loadSuccess == false)
          System.out.println("Error image " + imageName + " could not be located");
        return img ;
    }Francois

  • Show image when cursor hovers over image

    I would like to have the "i" image used to flip to the information screen be hidden or invisible unless the user hovers over the image, where I want the image to be visible and active after a second or two delay. This will allow a click or touch in the image area without activating the screen change.
    I've seen one or two iPhone apps which appear to do this, only showing the image when it is activated and otherwise the normal program image is visible and active. So, I know that it is possible. I'm just too new to objective C and the iphone SDK to know how to do it myself just yet.
    The standard utility app template which comes with the flipView controller and the "i" in the mainView appears to be always on. I'm sure there is a way to use view.hidden to hide and show it, but am not sure how to detect a hover then a touch, rather than just a touch.
    Any examples showing this would be appreciated.
    Thanks

    Some progress on this, but still working on it. I attempted to take the Utility Application template, and then add a subview to draw the layer with my own images. Somehow I don't seem to be able to get my new drawing to display. Instead I get a completely black view which also obscures the original view loaded from the nib.
    Can anyone tell me what I'm doing wrong?
    First, I take a blank Utility Application template, which shows the dark gray screen with the little information icon in the lower right corner.
    Next, add 2 class files which (1. Scenes.m) defines my sceneFiles and scenes structure which reads in my sceneFile.plist data into a dictionary structure so I can design my own layouts, and (2. Pieces.m) defines my board pieces, translation tables, and an image dictionary currently composed of PNG images read from individual files.
    Next, add code to MainViewController.m to initialize my view:
    @implementation MainViewController
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    // Custom initialization
    return self;
    - (void)viewDidLoad {
    UIView* mainView = [[MainView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)];
    [self.view addSubview:mainView];
    [mainView release];
    Now, in MainView.m I draw my view:
    - (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
    // Initialization code
    myPieces = [[Pieces alloc] init]; // setup piece images and index tables
    myScenes = [[Scenes alloc] init]; // read in scene file(s)
    sceneIndex = 0;
    currentSceneKey = [myScenes.sceneKeys objectAtIndex:sceneIndex];
    // begin drawing
    NSDictionary* myScene = [myScenes.scenes objectForKey:currentSceneKey];
    if (myScene) {
    NSString* sceneTitle = [myScene objectForKey:@"Title"];
    NSString* sceneTableau = [myScene objectForKey:@"Tableau"];
    for (int i=0; i<boardWidth; i++) {
    for (int j=0; j<boardHeight; j++) {
    NSRange myRange=NSMakeRange(((jboardWidth)+i)3,2);
    NSString* imgKey = [sceneTableau substringWithRange:myRange];
    NSString* newKey = [myPieces.backgrounds objectForKey:imgKey];
    UIImage* img=[myPieces.figures objectForKey:newKey]; // get image
    [img drawAtPoint:CGPointMake(i*cellSize, j*cellSize)];
    UIImage* title = [UIImage imageNamed:sceneTitle];
    [title drawAtPoint:CGPointMake(0,288)];
    [title release];
    } // if myScene
    // end drawing
    return self;
    Initially, the code between the "begin drawing" and "end drawing" was in the "drawRect" method, but it didn't seem to be doing anything, so I moved it to test it, and there was no apparent difference. I did put NSLog statements in drawRect and initWithFrame, and the code is being called. My images just aren't displaying.
    FYI
    // Scenes.h
    #import <Foundation/Foundation.h>
    #define boardWidth 15
    #define boardHeight 9
    #define cellSize 32
    @interface Scenes : NSObject {
    NSMutableArray* sceneFiles;
    NSMutableDictionary* scenes;
    NSMutableArray* sceneKeys;
    -(id)init;
    @property (nonatomic, retain) NSMutableArray* sceneFiles;
    @property (nonatomic, retain) NSMutableDictionary* scenes;
    @property (nonatomic, retain) NSMutableArray* sceneKeys;
    @end
    // Pieces.h
    #import <Foundation/Foundation.h>
    @interface Pieces : NSObject {
    NSMutableDictionary* figures;
    NSMutableDictionary* actions;
    NSMutableDictionary* backgrounds;
    NSMutableDictionary* foregrounds;
    -(id)init;
    @property (nonatomic, retain) NSMutableDictionary* figures;
    @property (nonatomic, retain) NSMutableDictionary* actions;
    @property (nonatomic, retain) NSMutableDictionary* backgrounds;
    @property (nonatomic, retain) NSMutableDictionary* foregrounds;
    @end
    I know that the initialization of the arrays and dictionaries in Scenes and Pieces is working correctly as well placed NSLog statements in the init routines display the proper text. The code is working in an OpenGLES template that was a hodgepodge of test cases, and now I'm trying to put the pieces together in a preperly designed project, and I'm getting a black sceen.
    The other project has a "myContext" variable, but as it was copied from some example code, I'm not sure how it is actually used, as most places the sample code was setting it to nil, and only one place at the beginning of drawRect, it was set to " UIGraphicsGetCurrentContext()". I've tried my code both with this and without it, and there does not appear to be any difference.

  • IPhone SDK - Drawing images

    Hello.
    I'm a beginner in Cocoa and Objective-C programming.
    I have to develop an application where I have to draw a map (a simple JPEG image) on the screen. I want to be able to zoom in and out on that map and to be able to move on that map by moving a finger on the screen.
    My image is a UIImage object.
    I tried two methods :
    - I created an UIImageView initialized with a CGRect (with its bounds corresponding to where I wanted to draw my image) and I added that UIImageView to my main view.
    It works well but when I want to zoom or to move on my image, I have to recreate always a new UIImageView with the new bounds, which uses a lot of resources.
    - I tried to override the drawRect method and in that method I tried to draw my image by using its drawInRect method with the CGRect object but it doesn't seem to have the same effect as creating an UIImageView with the same CGRect : the image is not resized to fill the rectangle.
    Could someone help me to understand that please ?
    Thank you.
    Patrick Schevenels.

    Thank you. I didn't know that property because it didn't appear in the code completion suggestions.
    Now, I still have a little problem : when I handle the touch events with the following code, I have a vibration effect on my image when I move it :
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    ancienpoint=touch.locationInView;
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    nouveaupoint=touch.locationInView;
    facteuroriginehorizontale += nouveaupoint.x-ancienpoint.x;
    facteurorigineverticale += nouveaupoint.y-ancienpoint.y;
    [self rafraichissement];
    ancienpoint=nouveaupoint;
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    "rafraichissement" is the name of the method to refresh the screen where I create a new CGRect with the new bounds (I add facteuroriginehorizontale to the previous x and facteurorigineverticale to the previous y) and I change the frame property of my image view.
    Thank you for your answer.
    Patrick Schevenels.
    Message was edited by: pscheven

  • Blast from the past: How do I draw image maps in Dreamweaver CC 2014?

    Need to update some old stuff, and can´t find where to draw image-maps on images.

    First, you need to be in Design View to get the image map tools to appear.
    Once there, the image map icons should show when you select an image. If they don't, you may have your Properties panel collapsed. In the bottom right corner of the Properties panel, there's a tiny triangle, click that to expand the panel to include the image map tools.

  • How to enlarge the image when the mouse is clicked

    I want to enlarge the image when the user click the image. How to do it by muse? Thank You!!!

    Hi,
    When you create a page in Muse called "Home" or "Gallery" or other else, when you export your site as HTML you must have a file called "home.html", "gallery.html" or "other else.html". Remember in what page you putted the Gallery in Muse and edit it with notepad, wordpad or similar and find the code where the gallery is linked (search the name of one of your images, is the best way to find it) and replace the code with something similar like that:
    <code>
    <a href="images/medidas06.jpg" rel="lightbox[gallery]"><img class="block ImageInclude" id="u3527_img" data-src="images/medidas06.jpg" src="images/blank.gif" alt="" data-width="248" data-height="360"/> </a>
    </code>
    The path to the JPG files must be ok with your website.
    The other steps are well explained by the readme of the lightbox library
    Regards

  • Color Matrix Alpha values and drawing images.

    Hi All,
    I am experimenting with using a color matrix to change images and have brightness, R, G, B changing but the alpha does not seem to do anything. I have a scrollbar for the alpha value in the matrix in the example. It seems it should change the image in some
    way but it does not.
    In this example I put 1 for red in the matrix thinking as I moved the scroll bar the alpha transparency would change the image in some way but it does not? It does not matter what colors or image I use nothing seems to happen with alpha? Is it
    only for drawing lines and such or does it do something to images? If so what?
    Imports System.Drawing.Imaging
    Public Class Form3
    Private rustybmp As New Bitmap("c:\bitmaps\rusty.jpg")
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.DoubleBuffered = True
    VScrollBar1.Maximum = 100
    VScrollBar1.Minimum = 0
    VScrollBar1.Value = 50
    End Sub
    Private Sub Form3_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
    Dim cm As ColorMatrix = New ColorMatrix(New Single()() _
    {New Single() {1, 0.0, 0.0, 0.0, 0.0}, _
    New Single() {0.0, 1, 0.0, 0.0, 0.0}, _
    New Single() {0.0, 0.0, 1, 0.0, 0.0}, _
    New Single() {0.0, 0.0, 0.0, 1.0, 0.0}, _
    New Single() {1, 0, 0, VScrollBar1.Value / 100, 1}})
    Dim image_attr As New ImageAttributes
    image_attr.SetColorMatrix(cm)
    e.Graphics.DrawImage(rustybmp, Me.ClientRectangle, 0, 0, rustybmp.Width, rustybmp.Height, GraphicsUnit.Pixel, image_attr)
    End Sub
    Private Sub VScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles VScrollBar1.Scroll
    Me.Refresh()
    End Sub
    End Class

    I didn't try this.
    How to: Use a Color Matrix to Set Alpha Values in Images
    La vida loca
    Oh, ok, in your link example the alpha is the 4 row 4 col.
    I was using the 5th row 4th col because I thought that was R, G, B A across the 5th row. Maybe that is for a solid brush or something.
    This works as I expected that way. Still looking....
    Dim cm As ColorMatrix = New ColorMatrix(New Single()() _
    {New Single() {1, 0.0, 0.0, 0.0, 0.0}, _
    New Single() {0.0, 1, 0.0, 0.0, 0.0}, _
    New Single() {0.0, 0.0, 1, 0.0, 0.0}, _
    New Single() {0.0, 0.0, 0.0, VScrollBar1.Value / 100, 0.0}, _
    New Single() {0, 0, 0, 0, 1}})
    Cool!
    Now if you could just get that working with HoloLens..... :)
    La vida loca

  • Draw image over Swing to mask.

    I have a window and I've overridden it make it draw all of it's components and then draw images over them (on a back buffer and then flip so the swing shouldn't ever be seen).
    It works perfectly and the swing components (JButtons and the like) catch the clicks when I click on the images masking them. The problem is when I click them for a very brief moment I see the Swing component come through. How is Swing doing this? Since I blt in a specific order and then flip. Somehow it is using the Graphics for the window directly - I overrode invalidate in a few ways but that just broke the components altogether.
    Anyone masked Swing components with images using a BufferStrategy? I would love some advice.

    AbstractButton (which JButton extends) calls JComponent.paintImmediately upon a click, so I don't think you can stop it without overriding AbstractButton and JButton (not recommended).
    Either override the paint method for your components to look like your overlaid image or remove your Swing components and test the mouse click location in the MouseListener.
    --Jon

  • Drawing Images. Making them Durable?

    Im trying to create an application that draws images to the screen. So for example, it draws an image (call it image x) where the user left clicks the mouse. It draws fine. Then when the user clicks at a new spot, the first image x is erased when the next is placed on the screen. This isn't what I want, I want all previous images from clicking to say. From searching, it seems my problem is that drawn images are not durable. Other forum posts didn't help me understand the solution to the problem so any help would be wonderful.
    Edited by: goyanks135 on May 12, 2009 6:13 PM

    Thanks for the quick reply, that seems to work best for this application. Another thing, is there any way to generate a BufferedImage that represents the panel? Currently I am using:
    <BufferedImage> = robot.createScreenCapture(<Rectangle>);
    to do so, but would not depending on where the window is on the screen. I couldn't figure out how to determine the windows location. Is there a method to create the BufferedImage or obtain the window's coordinates?
    edit: I was looking at the getLocation() and getSize() methods of the component class. Seems like they should work if I use
    <BufferedImage> = robot.createScreenCapture(new Rectangle (getLocation(), getSize());
    I'm going to bed right now and didn't get it to work. Seems like it should.
    Edited by: goyanks135 on May 12, 2009 7:01 PM

Maybe you are looking for

  • Not receiving group iMessages/texts

    First off - i know there have been lots of threads similar to this.  I've looked through those and tried the suggestions, but to no avail. I'm still left with the same issue. I've switched back and forth between my iPhone and Android phones for a cou

  • Crystal Report against ECC 6.0 with SSO configured

    I created a simple report against the ECC 6.0 Article table and saved it to InfoView. I can run the report fine, but when others run it they get an error stating the logon parameters are incomplete. We are in the process of configuring single sign on

  • 12 days of gifts - paused download, to resume the next day

    Hi, i downloaded 12 days of gifts and was trying to download a free video. I paused it then completely forgot about it. So can i still continue to download? Will i be charged? Or will it still be free? If i decide to not dowload and just delete it? H

  • Get iCloud contacts on my mac

    Ok im sure there must be a simple solution here. I am trying to sync everything on icloud with outlook mac, contacts/cal/notes etc, but I believe outlook will only sync with what is on my mac. Everything is in icloud and in my mac address book, i hav

  • Error 1418, 4th Gen 40GB Click Wheel

    I plugged in my iPod to the dock, and I get the Folder icon with the website underneath. So I open iTunes and it take forever to recognize it, and when it did, it told me it was corrupted. I go to restore it, and I get error 1418. I tried doing it in