How to draw an Image on a BufferedImage in a class that is not a Component?

I have an Image object loaded from a file using Toolkit, I want to draw it on a BufferedImage using g.drawImage( x, y, width, height, ImageObserver );
later on I want to save the BufferedImage in a jpeg file using the converter.
Since my class is not a subclass of Component (Panel, Applet, Canvas... ) what do I pass along as ImageObserver, nothing seems to be working, I can draw anything using g.draw... except an Image.
Thanks...
Fco. Espaillat

Try extending ImageObserver. You only have to implement one method, and its hardly an implementation. I ussually have that method return true regardless of what is going on and it works.
But to discourage bad programming style does anyone there know what that method is suppossed to return and how to find that out?

Similar Messages

  • How do I recover a file of images I removed from LR 4.3 that is not found in my desktop recycle bin?

    How do I recover a file of images I removed from LR 4.3 that is not found in my desktop recycle bin?

    I would try the following, in order
    Have your operating system search your entire hard disk(s)
    If that doesn't find the files, restore from backup
    If you don't have backups then perhaps you should consider making backups of both your catalog file and your photos from now on
    Locate, download and install and run an "undelete utility" (freeware versions are available) -- if you are going to do this, do it immediately, do not perform other tasks on your comptuer

  • How can I connect my 2009 Mac Mini to a TV that only has the Component inputs available? My Mac Mini has a Mini DisplayPort and Mini-DVI port. Thanks.

    How can I connect my 2009 Mac Mini to a TV that only has the Component inputs available? My Mac Mini has a Mini DisplayPort and Mini-DVI port. Thanks.

    Composite is analogue with one connector. That is why it is called composite
    Component is analogue with three connections. I think one for each color
    Here is the one for component. I misread composite for component
    http://www.amazon.com/DVI-I-Component-DisplayPort-Female-Adapter/dp/B003OBOJC2

  • HT5622 If I have two emails for my iMessage how can I see or receive my msj or the email that is not the primary email

    If I have two emails for my iMessage how can I see or receive my msj or the email that is not the primary email

    It's basically ment for iMessage and FaceTime. I might be wrong but this can only be done between two Apple products that allow this function. You won't receive an email if I sent you an iMessage to a secondary email you use for iMessages. You would only receive a text message. Now if someone using a PC sent an email to the secondary email you use you will receive an email not a text message. The secondary email is used basically if you do not have a data plan and you're connected to wifi you can still send iMessages using those emails you provided.

  • How do you connect to the enternet on a home pc that is not wifi?

    How do you connect to the enternet on a home pc that is not wifi?

    - An iPod will only connect to the internet via wifi. The USB connection does not provide internet conductivity.
    - When yu say phone line what type of phone line?  A regular (usually called dial up) would be very slow.  Do you have broadband phone like DSL,Fios or something?  You cold add wifi router to those. 

  • How to syncronize an iphone5S within a Macbook 10.5.8 that does not support the lattest version of ITunes?

    Does somebody know how to syncronize an iphone5S within a Macbook 10.5.8 that does not support the lattest version of ITunes?

    Macintosh System Requirements
    Mac computer with an Intel Core processor
    OS X version 10.6.8 or later
    400MB of available disk space
    Broadband Internet connection to use the iTunes Store
    You need to upgrade your OS X before installing the latest version of iTunes.  Then you will be able to sync your 5S.

  • How to draw an image at the center of a JscrollPane

    I have an image that I want to be centered in my JScrollPane. When I zoom-in, I want the image to fill the entire jscrollpane. When I zoom out it returns to the original scale. My problem is, when I open the image, it appears at the upper left corner of the JScrollPane. I want it centered. Also, when I zoom-in, it gets larger than the scrollpane. That is it goes beyond the boundaries of the JScrollpane. The function I am using to draw the image is:
    Image img = imp.getImage();
                   if (img!=null)
                        g.drawImage(img,0,0, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
                        srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height, null);If I change the initial x,y values from (0,0) to any other value, it grays the upper left corner. So forinstance, if I did the following, the upper left corner of the scrollpane would become gray.
    g.drawImage(img,100,200, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
                        srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height,null);How can I center my image in the scrollpane?

    When I zoom-in, I want the image to fill the entire jscrollpane. When I zoom out it returns to the original scaleSo why are you using a scroll pane? A scroll pane is used when its contents can potentially be larger than the scrollpane.
    Although it wasn't originally designed for this purpose you can probably use my [Background Panel|http://www.camick.com/java/blog.html?name=background-panel]. It supports displaying an image at its actual size as well as scaled to fit the panel. So you should just be able to toggle the style as required.

  • How to draw transparent image?

    i'm developing a java game, i wonder how to draw a transparent image, i'm using Image class, and Graphics class.

    http://search.java.sun.com/search/java/index.jsp?qp=forum%3A20&nh=10&qt=%2Btransparent+%2Bimage&col=javaforums

  • How to draw an image on transparent JPanel?

    I want to draw an image on the transparent JPanel. How to do it?
    I do like this:
    ( In constructor )
    setOpaque(false);
    String imageName = "coral.jpg";
    iimage_Bg = Toolkit.getDefaultToolkit().getImage(imageName);
    ( In paintComponent( Graphics g ) )
    Graphics2D g2D = (Graphics2D) g;
    g2D.drawImage( iimage_Bg, 0, 0, getWidth() , getHeight() , Color.white, null );
    But it doesn't work. Please help me!
    Thank you very much.
    coral9527

    Check the values that are returned from getWidth() and getHeight(). If they either are zero, then paintComponent(Graphics g) never gets called by the components paint(Graphics g) method. I cannot see the how this component has been added or displayed so can give no advice on how you can guarantee getting a valid size. If you have simply added it to a JFrame and called pack(), the size will be zero, as the panel does not contain any components (you would not have this problem if you were adding a JLabel with an ImageIcon for example). Try not packing the frame, and giving it a valid size.

  • How to draw an Image on a JPanel?

    Hi all,
    Can any one give code for drawing an image on a JPanel?
    thanks,
    amar

    That's for the JLabel right? ... For a JPanel on a JFrame, you could do something like this:
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    import java.net.URL;
    public class TestImagePaint  extends JFrame {
      private BjPanel bjp;
      public TestImagePaint( String imageName )   throws IllegalArgumentException {
        if ( imageName == null  ||  !( new File( imageName ).isFile() ) ) {
          throw new IllegalArgumentException( "\nIn TestImagePaint constuctor"
                                             +"\t IllegalArgumentException:" );
        bjp = new BjPanel( imageName );
        getContentPane().add( bjp );
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
        setBounds( 100, 100, 400, 300 );
        setVisible( true );
      public static void main( String[] argv ) {
        new TestImagePaint( argv[0] );
      public class BjPanel  extends JPanel {
        private URL   url;
        private Image image;
        public BjPanel( String imageName ) {
          try {
            url   = BjPanel.class.getResource( imageName );
            image = Toolkit.getDefaultToolkit().getImage( url );
            repaint();
          catch( Exception e ) {
            System.out.println( "Can't get Image: "+imageName+"\n\t"+e );
            System.exit( -1 );
        public void paint(Graphics g) {
          g.drawImage( image, 0, 0, this );
    }

  • How do I change my apple id from an old one that does not exist anymore to the new one I use....Please help me I can't update any downloads for my apps.

    How do I change my apple ID from an old one that doesnot exist anymore to a new old? When I purchased my macbook I had a mac.com email address but now have a me.com one. My computer is linked to the mac one. I cant update my apps....some one please help.

    Well when I first purchased I had an mac address, which I have not used for a long time I started a me address about 18months ago. and up untill I updated my iPhone I have been able to use my mac.com now I cant and dont know what to do because it tells me to verify my apple ID. I put in the password etc and doesnot take me anywhere as I cant access the emails.

  • HT201303 How do I get a refund from Apple for an album that did not download?  But they still charged me?

    How do I get a refund from the I tunes store for an album that did not download?

    See if you are able to redownload the album by clicking "Purchased", under Quick Links, at the top right of the iTunes store.
    Download past purchases:
    http://support.apple.com/kb/HT2519

  • How can I deactivate Photoshop Elements 5.0 on hard drive that will not boot?

    I have Elements 5.0 loaded on a hard drive which will no longer boot. I have a new hard drive and can access the old drive as an extra internal hard drive. I cannot use Photoshop, so I was thinking I need to deactivate the copy loaded on the old hard drive and reload it on the new hard drive. Is this the best solution? If so, how do I deactivate? When I start up the editor, it does not have an option for deactivating as I read about in another post. Under the help menu, there is a grayed out option for Registration. After a few seconds, a window appears saying there is a problem with my serial number and the application closes.  Also, I would like to load Photoshop on a laptop later, so I do not want to waste one of my allowable loads. I would appreciate any help.

    Yes, as long as you don't have it on more than two computers at once you're in compliance with the license. (Back in the days of PSE 5 adobe worked more on the honor system.)

  • How do i ADD a file type (such as Quicktime mov) that is NOT listed in the Content Type list?

    All the instructions I find when searching for how to ADD a file type just explain how to manage how Firefox handles that file type. And that is not possible when the file type is not in the list.

    Usually MOV is played by the QuickTime plugin. Some other plugins also may handle MOV. This is handled by entries in a hidden database, but you can view the contents if you type or paste about:plugins in the address bar and press Enter.
    In looking at your plugins list under "More System Details" I don't see QuickTime. Is it disabled (set to "never activate") on the Add-ons page? Missing?
    Tools menu > Add-ons > ''in the left column, click'' Plugins

  • How do I install my photoshop elements to my new laptop that does not have a cd disk drive?

    How do I install my photoshop elements 12 to my new laptop that does not have a disk drive?

    download pse 12 trial and activate with your serial number, http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop_elements

Maybe you are looking for

  • How can I get the download of Premiere Elements 12? It's missing from the Photoshop & Premiere 12 bundle..

    I purchased the upgrade bundle of Photoshop Elements 12 and Premiere Elements 12 for download today. Photoshop downloaded fine, but Premiere Elements Is nowhere to be found. Where can I access that download?

  • What are credentials/tokens needed to connect to FMS

    I'm trying to connect to FMS with Wirecast and keep getting this error Cannot publish the stream. Verify the stream name and if you have provided any credentials/tokens that they are up to date. [-4020]that they are up to date. and of course, can not

  • ALE-IDOC ISSUE(material getting locked for enhancement)

    Dear all, I have extended the idoc and enhanced inbound material master function module to suite the requirement . The challenge is that the material is getting locked when the material sent from bd10 and prodction version view for which function mod

  • Laptop satellite

    My laptop was running updates through Microsoft essentials it said not to turn off computer well we had a power outage so when I turned it back on it was stuck on loading updates I've tried rebooting just about everything even trying to load a window

  • Deletion of Mobile / telephone numbers from customer master XD03

    Hi Gurus, I need to delete all the mobile numbers from various customers (more than 500) in customer master XD03. I tried deleting the telephone number entries directly from ADR2 table, but it showing inconsistancy. Can anyone guide me how can i mass