PLEASE HELP ME to put an image over a background image !!

Hello,
I need help on my AWT program. I have a map being displayed, and would like an image of a car (car.gif) to be displayed over the image of the map.
So my question is: How do I make this map a background image, and put the picture of the car right over it. I need my map loaded all the time, and the picture of the car will be reloaded many times over the same map, so a class method to load this map would be perfect. Any help, code, or suggestions would be great. Thanks so much!
Here is what I currently have for my map.
import java.awt.*;
import java.awt.event.*;
public class MyImage extends Panel {
    private Image im = null;
    Graphics g;
    public void getMap(){
      im = Toolkit.getDefaultToolkit().getImage("C:\\test_map.gif");
         MediaTracker tracker = new MediaTracker(this);
         tracker.addImage(im,0);
         try {
             tracker.waitForID(0);
         }catch (InterruptedException e){}
             repaint();
   public void paint(Graphics g){
        this.g = g;
         if (im != null)     {
            g.drawImage(im,0,0,this.getWidth(),this.getHeight(),this);  //706,397
    }

Look at this sample, the car will start when the button will be pressed, and stop on the next press.
import java.awt.event.*;
import java.awt.*;
public class UsaTrip extends Frame 
     mapPanel map   = new mapPanel();
     Button   move  = new Button("Move");
     TheMover mover = null;
public UsaTrip()
     addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     setBounds(10,10,500,400);
     setLayout(new BorderLayout());
     add(map,BorderLayout.CENTER);
     add(move,BorderLayout.SOUTH);
     move.addActionListener(new ActionListener()
     {     public void actionPerformed( ActionEvent e )
               if (mover == null)
                    mover = new TheMover(map);     
                    move.setLabel("Stop");          
               else
                    mover.end();
                    mover = null;     
                    move.setLabel("Move");          
     setVisible(true);
public class TheMover extends Thread
     mapPanel map;
     boolean  go   = true;
     int      spin = 0;
public TheMover(mapPanel m)
     map = m;
     start();
public void end()
     go        = false;
public synchronized void run()
     while (go)
          map.moveCar();
          try     {sleep(100);}
          catch(InterruptedException i){}
public class mapPanel extends Panel
     Image map;
     Image car;
     int   x=10,y=30;   
public mapPanel()
     map = getToolkit().getImage("usa.gif");
     car = getToolkit().getImage("home24.gif");
     MediaTracker tracker = new MediaTracker(this);
     tracker.addImage(map,0);
     tracker.addImage(car,0);
     try   {tracker.waitForID(0);}
     catch (InterruptedException e){}
public void moveCar()
     repaint(x,y,25,25);
     x++;
     repaint(x,y,25,25);
public void update(Graphics g)
     paint(g);
public void paint(Graphics g)
     Rectangle r = g.getClipBounds();
     g.drawImage(map,r.x,r.y,r.x+r.width,r.y+r.height,
                          r.x,r.y,r.x+r.width,r.y+r.height,this);
     g.drawImage(car,x,y,this);
public static void main(String[] args )
     new UsaTrip();
Noah
import java.awt.event.*;
import java.awt.*;
public class UsaTrip extends Frame
     mapPanel map = new mapPanel();
     Button move = new Button("Move");
     TheMover mover = null;
public UsaTrip()
     addWindowListener(new WindowAdapter()
{     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     setBounds(10,10,500,400);
     setLayout(new BorderLayout());
     add(map,BorderLayout.CENTER);
     add(move,BorderLayout.SOUTH);
     move.addActionListener(new ActionListener()
     {     public void actionPerformed( ActionEvent e )
               if (mover == null)
                    mover = new TheMover(map);     
                    move.setLabel("Stop");          
               else
                    mover.end();
                    mover = null;     
                    move.setLabel("Move");          
     setVisible(true);
public class TheMover extends Thread
     mapPanel map;
     boolean go = true;
     int spin = 0;
public TheMover(mapPanel m)
     map = m;
     start();
public void end()
     go = false;
public synchronized void run()
     while (go)
          map.moveCar();
          try     {sleep(100);}
          catch(InterruptedException i){}
public class mapPanel extends Panel
     Image map;
     Image car;
     int x=10,y=30;
public mapPanel()
     map = getToolkit().getImage("usa.gif");
     car = getToolkit().getImage("home24.gif");
     MediaTracker tracker = new MediaTracker(this);
     tracker.addImage(map,0);
     tracker.addImage(car,0);
     try {tracker.waitForID(0);}
     catch (InterruptedException e){}
public void moveCar()
     repaint(x,y,25,25);
     x++;
     repaint(x,y,25,25);
public void update(Graphics g)
     paint(g);
public void paint(Graphics g)
     Rectangle r = g.getClipBounds();
     g.drawImage(map,r.x,r.y,r.x+r.width,r.y+r.height,
               r.x,r.y,r.x+r.width,r.y+r.height,this);
     g.drawImage(car,x,y,this);
public static void main(String[] args )
     new UsaTrip();

Similar Messages

  • How to overlay color image over a grayscale image without IMAQ?

    I would like to display a color image over a grayscale image; I would like the color image look translucent. How would I do this without using IMAQ functions? I am currently displaying my grayscale image using Intensity Graph.

    > I would like to display a color image over a grayscale image; I would
    > like the color image look translucent. How would I do this without
    > using IMAQ functions? I am currently displaying my grayscale image
    > using Intensity Graph.
    Transparency and overlays are really just arithmetic on the images. It
    is either done by the windowing system or by you. At the moment you
    can't set transparency on LV controls. You can set it on LV floating
    windows on some OSes, but then you will need to have the windows lined up.
    A more direct approach is to lighten or darken the color image elements
    based upon whether they will display over white, black, or a shade of
    gray. If the images don't have the same size pixels, this will have a
    first step of resampling th
    e images so they do. Then combine the pixels
    using the transparency you were going to apply to the color and the
    shade of gray beneath it. I'm being vague here because there are lots
    of physical models for combining colors.
    If I look in my paint program I see about fifteen, so this is where you
    get to make a choice and decide if black behind a red pixel is black, or
    dark red. It all depends on whether these are two transparent
    images(acetate sheets) backlit, or is it a transparency over a
    nontransmitting media like paper. Anyway, if you can be more specific
    about what you want, none of this is hard, typically just scaling the
    int32s, adding, and some sort of normalization.
    Greg McKaskle

  • Please help.downloading apps from ovi store over w...

    i simply cannot download a single application from ovi store over wifi.its too costly over 3g .please help me.latest firmware updated.

    You dont have change your wifi settings.(I hopr you dont have any probs with your internet connection)
    Use this installation files and install reps.
    http://my-maemo.com/download/repos/extras.install
    http://my-maemo.com/download/repos/extras-testing.install
    http://my-maemo.com/download/repos/extras-devel.install
    And also check your nokia catalogues  from appmanager.
    "You may loose faith on us.. But never in your selves! From here, the fight will be your own.."
    _____________[Protect Transformers]_____________

  • Can someone please help me? I have lost over 24 hours of work done in Acrobat.

    To give you the background of what keeps happening is I compile a pdf on my macbook pro from several different documents I need to put together. Then I uploaded it to an email account and downloaded and saved it on my pc (Windows XP and Acrobat 9) in order for me to add more individualized Bookmarks and text boxes. The total file size (if this matters at all) is 57MB. I added hundreds of Bookmarks, text boxes and highlighting to the pdf and saved it every 10 minutes (this is in addition to my Acrobat program being set to autosave every 5 minutes). The file saved my additions and changes no problem. When I was finished working for the night I saved the file and closed it before shutting down my pc. The next day when I opened the pdf to continue working on it NONE of my bookmarks, text boxes or highlighting was there with the exception of a few changes I made to the wording of of a couple original bookmarks. I do not understand where all my work went or if there is any way to get it back. If anyone knows what is going wrong or how I could recover my work please respond to my posting. I am afraid to work on the document anymore because this was not the first time this has occurred. PLEASE HELP ME!!

    I have no clue about recovering the info, but when you say you save you should always use Save As. That clears unneeded info from the file. With the file size you have, that may be an important need.

  • Please help: How to undo accidental paste-over in NOTES?

    Please help: just pasted over an entire (very important) note in an epic fat-finger touch. Please let me know if there is a "command Z" type action I might be able to take to undo, go back, etc. I have not connected phone to sync just yet to see what might be backed up- until I know if there is any way to retrieve the most recent info I just lost. Desperately hoping for an answer out there.

    You cannot view the contents of your backup file.  Your backup does contain notes, but if you can't remember when you last backed up relative to when you created or revised the note, then you can try checking the date stamp of the backup file to see when it was last done (or, if you backup to iCloud then your Settings will tell you).

  • PLEASE HELP!!! using servlet to generate an image in jsp page

    Hi,
    I am so stuck on this... please help.
    I have a servlet that generated a gif image dynamically. It uses a bean that stores the gif image in a byte array.
    The servlet outputs the byte data to the output stream. The code is really simple and looks like this:
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //HttpSession session = request.getSession();
            try {
                ServletOutputStream stream = response.getOutputStream();
                ImageByteInformation imageByteInfo = (ImageByteInformation) request.getAttribute("imageByteInformation");
                response.setContentType("image/gif");
                response.setContentLength(imageByteInfo.getByteData().length);
                stream.write(imageByteInfo.getByteData(), 0, imageByteInfo.getByteData().length);
                stream.flush();
            }catch( Exception e){   
                System.out.println("You are hooped!: " + e.getMessage() + " " + e.toString());           
            }When I redirect from the dispatch servlet straight to this servlet an image shows up in the browser window.
    However when I try to use this jsp page to display the image nothing happens...
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h2>Hello World!</h2>
            <img src="servlets/Map24ImageDisplayServlet"/>
             //I also tried src/servlets/Map24..., /src/servlets/Map24..., /display, servlets/display
            <h2>Did you see the image?</h2>
        </body>
    </html>My web.xml is here if it helps...
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <display-name>HelloProject</display-name>
    <servlet>
        <display-name>ServletDispatcher</display-name>
        <servlet-name>ServletDispatcher</servlet-name>
        <servlet-class>servlets.ServletDispatcher</servlet-class>
      </servlet>
      <servlet>
        <display-name>Map24ImageDisplayServlet</display-name>
        <servlet-name>Map24ImageDisplayServlet</servlet-name>
        <servlet-class>servlets.Map24ImageDisplayServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>ServletDispatcher</servlet-name>
        <url-pattern>/hello</url-pattern>
      </servlet-mapping>
      <error-page>
        <error-code>404</error-code>
        <location>/404_error.html</location>
      </error-page>
      <servlet-mapping>
        <servlet-name>Map24ImageDisplayServlet</servlet-name>
        <url-pattern>/display</url-pattern>
      </servlet-mapping>
    </web-app>I can never get an image to come up. In fact I can never get the jsp page to run the servlet at all! HELP!!! What am I doing wrong?
    Thanks
    Edited by: Kind_of_Green on May 5, 2008 3:55 PM
    Edited by: Kind_of_Green on May 5, 2008 4:00 PM

    OK... so you WERE absolutely right about the src path for the image tag.
    However I also had another problem that was quite a bit more insidious and mostly just a symptom
    of how little I know about what goes on under the hood of a web app.
    My bean storing the image info was stored as a request attribute. When the servlet was called from the
    jsp page the request object was either reset or just never initialized. Anyway it is not the same request
    object I assumed it was being passed in the doGet method. I added my bean as a session
    attribute and everything is sparkly :)
    I can only assume that when a request is neither forwarded nor included (as is the case with
    calling the servlet from the img tag) it is disappeared.
    Anyway, thanks a mint man. I so totally appreciate your time.
    Ciao :)

  • Creative cloud app has gone and i can't open programme. have client waiting for tiny amend to ai file and can't get any help! please help! this has taken me over an hour trying to get anything to work again...

    Oh the infinity symbol has disappeared (It was there at first but then when I tried to log in it froze up and I had to quit) Opening the programme Ai just brought up a bouncing ai icon which quickly turned to adobe updater - which did not respond. so i have read on the boards you need to delete update which i have done but now it just says i need it…. i can't log in… am very worried as i have to urgently sort something by half five and have no help from previous messages and am currently still on hold (have being transferred from you instantly asked sales line) waiting for help… please help!

    Nobody can help you without proper system and version information or other technical details. if the update is botched, then run the cleaner tool and reinstall from scratch.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    Mylenium

  • And again - how do I superimpose an image over a moving image?

    So I am beginning to work this all out...
    I have cropped an image using motion which is looking great, except that the image (which is someone's head) is square because I used 'crop' in motion, any ideas how to make the edges curved?
    The next step is working out how to keep the superimposed image over the head of the person in the video if they move? ie so it tracks the original image in movement?
    Thank you all for your help so far, I never expected help like this so quickly!

    Hard to follow you when you're creating new threads on the same topic...
    First of all - don't use Motion to crop - that's easily done in FCP - if you want to follow the edges of the head, use the Mask tool in Motion.
    Second, there's a video tutorial for using the tracking tools in Motion here:
    http://motionsmarts.com/
    Patrick

  • Transparency issues with images over color backgrounds

    I have a transparent .png that I place over a color background. When I do this, there's a slight discoloration in the image's transparent background. As a result, it looks the image really isn't transparent, but has a slight white background. I can't seem to get rid of this and have tried for days. Can anyone help me out here?

    Thanks Robert. You're a lifesaver. This trick totally worked. You saved me a huge headache. I appreciate it.

  • How to project an image onto a background image?

    Hi,
    I am looking for help with projecting an image over another image.
    I am looking for a similar effect to the image above where it looks like the image of the player as (physically) been projected onto the tunnel.
    Looking closely at the detail of the image you can see that the projection adjusts to the contours of the tunnel i.e. over the framing. This is what I specifically need some help with. I know how to overlay an image onto another using different layers but it doesn't really give a three-dimensional perspective and looks rather flat.
    Any help or advice would be greatly appreciated. Thanks
    Ravi.

    Hi Ravi -
    Could you post what you have done so far, and include your expanded layers panel? The source images would also be helpful, if possible!
    One thing you could try is creating a Displacement Map of your background tunnel image and then wrapping your overlay image to it. The video tutorial below shows you how to do this:
    Beside this, you might just have to spend time tweaking your image to create a realistic overlay. This includes adjusting lighting, but also distorting your overlay image. Have you tried using Edit > Transform > Perspective to align your image to the tunnel? The other Transform tools like Distort and Warp might also come in handy.
    I'm looking forward to helping you with this effect!
    Cheers,
    Kendall

  • Two Images in PDF (background image)

    Greetings
    Trying to replace an existing image in a report from filesystem and this replace an existing loaded image into the reports. This image should come as back of the photo for an ID Card. As it comes from the file system it pushs the photo in the background, which has to be in the foreground. So the filesystem image (pointing to a file in OS) in the background, the photo image from the database should sit on top of the OS image. This works fine earlier if the image is loaded into the report instead of file system.
    I am using 10g reports, any idea how will use the file system image in the background and push the photo image comes from the database on top of it.
    thanks

    Please ignore this thread. Has resolved. Removed both images and put the background image first and recreate the database image on top of file system image later, so it works now.
    The solution (just in case) is remove both images and recreate them in the order, i.e the background image first and the foreground image later.
    Cheers

  • Hello I put protection on your iphone 4 and forgot about please help, Hello I put protection on your iphone 4 and forgot about please help

    Hello I put protection on your iphone 4 and forgot about please help

    If you forgot your passcode, read here: http://support.apple.com/kb/HT1212
    If you've forgotten your Apple ID and/or password, read here: http://support.apple.com/kb/HT5787
    If neither of those helps, let us know. Please tell us exactly what you see on your iPhone's screen, including the exact message displayed.
    ~Lyssa

  • I am trying to put a JButton over an animated image series

    can anyone help me?
    What I am doing is running a series of 6 images one after the other in an animation, JApplet animation, and I can't get the JButtons to apear over the pictures without totaly blocking the pictures off, or greating one big button, or just not apearing.
    I would really apreciate the help
    Thanks in advance.

    Ok um do you know were I could find this information.Model-View-Controller:
    Building Graphical User Interfaces with the MVC Pattern
    Java BluePrints - Model-View-Controller
    MVC meets Swing
    Patterns Overview:
    The Design Patterns Java Companion
    Head First Design Patterns
    Huston Design Patterns
    Overview of Design Patterns

  • Please Help. Can't Remember What I Did. (Images Attached)

    Ok. I Had Been Working On This Drawing For Hours A While Back, Trying To Get A Certain Pattern Effect. I Pretty Much Got What I Wanted On A Few Layers. I Cannot Remember What I Did Though.
    I've Highlighted The Layers I'm Referring To. First Off, Why Are There Blank Layers Next To The Pattern Layers With Chain Links Between Them?? Also I Know I Did Some Kind Of Pattern Fill. But When I Did It, I Was Able To Resize It. Now When I Try To Do A Regular Patterns It Just Puts It At A Default Size.
    This Layer Is Different Than The Rest. When I Click On It This Menu Comes Up.
    But When I Click On Any Of The Other 3, This One Comes Up.
    I Had Worked Really Hard To Make Those Layers.. I Just Simply Cannot Remember At All What I Did..
    Any Insight On What It Looks Like I Did Would Be Very Helpful. Thank You

    Press and hold an app icon until it wiggles. Drag it over top of another icon. A folder will be created.

  • Please help me transfer my music folders over.

    Hi, I have itunes and ifunbox (which allows me to connect into the file system level of the iphone) and am wondering which would be the simplest way to transfer some of my music over?
    I have already imported all of my music into itunes, but it's really hard to have them sync-ed as all I am looking to do is to select certain folders from certain artists (not all music from a particular artist I want to sync) and have it transferred to my iPhone.
    Now I could probably do this simply if it was a drag and drop operation: Select multiple album folders I have in windows and then copy it to the iphone via the file system interface.
    Is this even possible? Or can it be done in iTunes in an easy manner? I really don't want to see all the songs, maybe if I could summarise all the songs in a certain album or artist, then select which albums I want to transfer, that would be easier?
    Help much appreciated. Thanks.

    I had a large library of music in i tunes, It is also all on my old ipod nano, I got a new iphone and set it up using i tunes and now all of my music libary has dissappered and now the only tunes in the library are the ones I have purchased recently from i tunes and not the hundreds of albums I have copied into itunes previously.
    Very strange. If you glibly sync an iPod with a computer with nothing in the library, it's easy to wipe out the iPod, but it's not designed to do that the other way!
    How do I get the music from my ipod back into my libary? If I sync my ipod I am told by itunes I will loose all my music on the ipod (and weeks of copying my own cds.) Once I have my music in the itunes library how do I then transfer it onto my new iphone?
    Two possibilities. The music may still be on your computer's disk, just not included in your iTunes library. If you go to the music folder on your hard drive (using Windows' Explorer or the Mac's Finder window), you can see if the music is still there somewhere. Look under "Music" and you probably have an iTunes folder inside there. If it's there, in iTunes you can select "File" - "Add Folder to Library", and the music should reappear (though playlists will have to be regenerated).
    Alternatively, if the music is truly gone from your computer's hard drive (check your Mac Trash or PC Recycling bin, too), you can restore whatever you still have on your iPod. See the following article, which touches on the topic of recovering music from an iPod.
    http://support.apple.com/kb/HT1329

Maybe you are looking for

  • Pse 8 for mac: turn off tabs in workspace?

    I am finding the tabs across the top of the workspace get in the way when i am using tools and modifying them etc, mousing over the tab to get to the modify options, activates the tab label pop up, which blocks my use of the modifyers -- hope that ma

  • Play through camera

    I have a Panasonic GS500 digital camera and using Final Cut Express 3.5. I am able to play the video through to the camera to record without any problems using iMovie, but it is not coming through from Final Cut Express. It was actually working yeste

  • Photoshop Camera Raw to Premiere Pro

    I've gotten used to processing still images in Photoshop's Camera Raw converter.  Is there any way to export/copy the settings from the Photoshop raw converter to apply to footage in Premiere Pro (or through Speed Grade and then to Premiere Pro)? If

  • Previous message in email reply

    On the original iPhone, is there a way to turn off the inclusion of the previous message when replying to an email? Hitting reply and then deleting previous messages (especially long stings of conversation) gets tedious after a while. LOL

  • ERRORS screen and system...

    Hello , I have a problem with my toshiba lap top and screen..