Copy offscreen image to applet

I drew points to an offscreen Image and tried to copy it to my applet, but the applet is just white.
my code:
    public void paint (Graphics g)
        Image Drawing = Background;
        Drawing.getGraphics ().setColor (Paint);
        int Index = 0;
        while (Index < points.size ())
            Drawing.getGraphics ().drawLine ((int) Math.round (((Point) poins.get (Index)).getX ()), (int) Math.round (((Point) points.get (Index)).getY ()), (int) Math.round (((Point) points.get (Index)).getX ()), (int) Math.round (((Point) points.get (Index)).getY ()));
            Index = Index + 1;
        g.drawImage (Drawing, 0, 0, this);
    }what am I doing wrong?
(oh yeah, and is there a better way to draw points, or do I really have to draw 1x1 pixel lines?)

It is true that turning off graphics acceleration eliminates the problem, but you can't publish an applet that requires every user turn off hardware acceleration on their PC. The problem has to be either fixed in the awt (unlikely since 1.6.10 is at RC) or bypassed in the applet.
So, if you are reading this because you have a production applet broken by the changes in Java 1.6.10, I am afraid you are going to have to make changes to your paint routine to avoid the applet using any drawImage coordinates that reference areas outside the clip region of the graphics context.

Similar Messages

  • Copy Paste image in applet

    Hi,
    I'm working on a Java picture editor (a JApplet), and I was wondering if there was a way to directly copy/paste an image onto a canvas of some sorts (ie, copy/paste directly to the applet). Is it possible, and how would it be done? I'm a little new to Java, so I'd greatly appreciate some insight!

    reproduced on 7-32bits
    I've 10.000 customers on this platform, currently on adobe7/8/9, and waiting for this "go" to update.
    Is it possible to have an answer ?
    Thanks.
    For references : HP 6005 Pro
    chipset AMD 785G (Radeon HD 4200)
    drivers updated...

  • How to draw a JPanel in an offscreen image

    I am still working on painting a JPanel on an offline image
    I found the following rules :
    - JPanel.setBounds shall be called
    - the JPanel does not redraw an offline image, on should explicitly override paint()
    to paint the children components
    - the Children components do not pain, except if setBounds is called for each of them
    Still with these rules I do not master component placement on the screen. Something important is missing. Does somebody know what is the reason for using setBounds ?
    sample code :
    private static final int width=512;
    private static final int height=512;
    offScreenJPanel p;
    FlowLayout l=new FlowLayout();
    JButton b=new JButton("Click");
    JLabel t=new JLabel("Hello");
    p=new offScreenJPanel();
    p.setLayout(l);
    p.setPreferredSize(new Dimension(width,height));
    p.setMinimumSize(new Dimension(width,height));
    p.setMaximumSize(new Dimension(width,height));
    p.setBounds(0,0,width,height);
    b.setPreferredSize(new Dimension(40,20));
    t.setPreferredSize(new Dimension(60,20));
    p.add(t);
    p.add(b);
    image = new java.awt.image.BufferedImage(width, height,
    java.awt.image.BufferedImage.
    TYPE_INT_RGB);
    Graphics2D g= image.createGraphics();
    // later on
    p.paint(g);
    paint method of offScreenPanel :
    public class offScreenJPanel extends JPanel {
    public void paint(Graphics g) {
    super.paint(g);
    Component[] components = getComponents();
    for (int i = 0; i < components.length; i++) {
    JComponent comp=(JComponent) components;
    comp.setBounds(0,0,512,512);
    components[i].paint(g);

    Unfortunately using pack doesn't work, or I didn't use it the right way.
    I made a test case, eliminated anything not related to the problem (Java3D, applet ...). In the
    test case if you go to the line marked "// CHANGE HERE" and uncomment the jf.show(), you have
    an image generated in c:\tmp under the name image1.png with the window contents okay.
    If you replace show by pack you get a black image. It seems there still something.
    simplified sample code :[b]
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import com.sun.j3d.utils.applet.*;
    import com.sun.j3d.utils.image.*;
    import com.sun.j3d.utils.universe.*;
    import java.io.*;
    import java.awt.image.*;
    import javax.imageio.*;
    public class test {
    private static final int width=512;
    private static final int height=512;
    public test() {
    JPanel p;
    BorderLayout lay=new BorderLayout();
    java.awt.image.BufferedImage image;
    // add a JPanel with a label and a button
    p=new JPanel(lay);
    p.setPreferredSize(new Dimension(width,height));
    JLabel t=new JLabel("Hello");
    t.setPreferredSize(new Dimension(60,20));
    p.add(t,BorderLayout.NORTH);
    p.setDebugGraphicsOptions(DebugGraphics.LOG_OPTION );
    // show the panel for debug
    JFrame jf=new JFrame();
    jf.setSize(new Dimension(width,height));
    jf.getContentPane().add(p);
    [b]
    // CHANGE HERE->
    jf.pack();
    //jf.show();
    // create an off screen image
    image = new java.awt.image.BufferedImage(width, height,
    java.awt.image.BufferedImage.TYPE_INT_RGB);
    // paint JPanel on off screen image
    Graphics2D g= image.createGraphics();
    g.setClip(jf.getBounds());
    System.err.println("BEFORE PAINT");
    jf.paint(g);
    System.err.println("AFTER PAINT");
    // write the offscreen image on disk for debug purposes
    File outputFile = new File("c:\\tmp\\image1.png");
    try {
    ImageIO.write(image, "PNG", outputFile);
    } catch (Exception e) {
    System.err.println(e.getMessage());
    g.dispose();
    jf.dispose();
    public static void main(String[] args) {
    test t=new test();
    }

  • Copy & Paste images to forms from the clipboard

    hello,
    Java Plug-in 1.6.0_33
    Using JRE version 1.6.0_33-b05 Java HotSpot(TM) Client VM
    Forms Applet version is 11.1.2.0
    Windows 7 64bitForms has successfully done the drag&drop,save image file images to javabeans then save & retrieve it from database.
    Laf project has an example of table-block copy/paste from/to the clipboard feature. You can populate a table-block with the content of the clipboard (Excel, Word,...) and also send to the clipboard with the content of a table-block.
    But a how about the copy & paste images to forms?
    It is posible?Any one tried this one?
    Charles
    Edited by: ck on Aug 12, 2012 3:09 AM

    bump...

  • PB: PixelGrabber, offscreen Image, Windows 98, ie5

    Hello,
    I've got a problem with a bug that occurs under Windows 98, and ie5.
    This is the code of a little applet that works fine under Windows NT, but not under Windows 98:
    This applet draws 3 colors in a square, and use the grabPixel method for catching the pixels of the image and create another image with those pixels.(the image should be the same)
    The problem is that the grabPixel method changes the colors of the pixels. It occurs only with an offscreen Image (that means an Image created with the createImage(w, h) method). there is no problem with a MemoryImageSource, for example.
    I just notice that the ColorModel of an offscreen Image is not the same as the default ColorModel:
    colorModel: java.awt.image.DirectColorModel = {...}
    red_mask: int = 0xf800 (instead of 0x00ff0000 )
    green_mask: int = 0x7e0 (instead of 0x0000ff00 )
    blue_mask: int = 0x1f (instead of 0x000000ff)
    alpha_mask: int = 0x0 (instead of 0xff000000)
    red_offset: int = 0xb
    green_offset: int = 0x5
    blue_offset: int = 0x0
    alpha_offset: int = 0x0
    red_scale: int = 0x1f
    green_scale: int = 0x3f
    blue_scale: int = 0x1f
    alpha_scale: int = 0x0
    But i don't know how to solve the bug.
    Here is the code :
    import java.awt.*;
    import java.awt.image.*;
    import java.applet.*;
    public class AppletFlush extends Applet implements Runnable{
    Thread anim;
    Image memimg;
    boolean bool;
    Image offImage;
    Graphics offGraphics;
         public void init() {
         public void start() {
         anim = new Thread(this);
         anim.start();
    bool = true;
    offImage = this.createImage(100, 100);
    offGraphics = offImage.getGraphics();
         public synchronized void stop() {
         anim = null;
         notify();
         public synchronized void run() {
         while (Thread.currentThread() == anim) {
    int[] pixels = new int[100 * 100];
    int color = 0;
    //set the pixels of a squared image that contains 3 colors (this is my reference image)
    if (bool)
    bool = false;
    for (int i=0; i<100; i++)
    if (i<33)
    color = 0xffff0000;
    else if (i<66)
    color = 0xff00ff00;
    else
    color = 0xff0000ff;
    for (int j=0; j<100; j++)
    pixels[i*100 + j] = color;
    else
    //grab the pixels of the offscreen image(here is the problem)
    PixelGrabber pg = new PixelGrabber(offImage, 0, 0, 100, 100, pixels, 0, 100);
    try
    pg.grabPixels();
    catch (InterruptedException ex)
    System.out.println("erreur pendant gragPixels !!!");
    //create the new image with the pixels
    MemoryImageSource imgsrc = new MemoryImageSource(100, 100, pixels, 0, 100);
    memimg = createImage(imgsrc);
    //draw the image in the offscreen image
    offGraphics.drawImage(memimg, 0, 0, null);
              repaint();
              try {wait(1000);} catch (InterruptedException e) {return;}
         public void paint(Graphics g) {
         // display the offscreen image
         g.drawImage(offImage, 0, 0, this);
    PLEASE HELP !
    YaYa

    try
    public void paint(Graphics g )
    if((_offScreen != null)&&(offScreenImage != null))
    // put your stuff here
    else
    update(g);
    g.dispose();
    g.finalize();
    return;
    public void update(Graphics g)
    if( offScreenImage == null)
    offScreenImage = this.createImage( width, height );
    if( _offScreen == null)
    _offScreen = offScreenImage .getGraphics();
    paint(g);
    }

  • Painting in a thread without offscreen image

    I'm trying to develop a good map viewer with java. Now, painting a map can
    be a very long task, and the requirements for a good map viewer should be:
    * the user can see progress, that is, the map is painted incrementally on the
    screen, not offscreen, otherwise the user has to sit and wait looking at
    a gray pane for seconds (a complex map may take 20-30 seconds to paint)
    * the user can stop rendering, or, if the panel is resized, the rendering should
    immediatly restart.
    The second requirement could be achieved by painting in a separate thread
    onto a BufferedImage and then invoke paint back to copy the image onto
    screen, but this approach fails to meet the first requirement... is there any way
    to paint directly on the screen without blocking the swing event thread?
    Moreover, ins't the hardware acceleration lost by using an offscreen image?

    To achieve visibly incremental progress of painting on the panel, probably you can use a JTimer and set the delay to 1000ms. In this frequency you can paint the panel in an incremental fashion. This approach will help you to achieve the other requirement of stopping the progress in the middle. You can provide a button, so that if the user presses the button, then invoke stop() method of timer which eventually stops the progress of the panel. Also if you want, you can restart() the progress from the point where it got stopped previously, by invoking restart() method of timer.
    Obviously, you should have a method which does all your painting and so on. Here JTimer can be helpful only in stopping, restarting and delaying the progress. Finally, make sure that the painting method is handled by JTimer alone.
    Hope this helps.

  • Secure display of copy protected images

    I'm creating an applet that should be able to display the images to a users screen - without enabling him to copy the images in any way (e.g. by doing a screenshot).
    I realize this is a difficult (if not impossible) task - as long is the user can view an image, it can be copied.
    But if I can reduce the amount of people that will be able to do it, that should be good enough.
    This is how I'm thinking of doing it;
    1. The images are stored in an area on the server that isn't accessible from web
    2. A script will read the image data and hand it to the applet
    3. The applet will display the image in a cardlayout (image / blank)
    - when keyboard events are received the blank card will be shown
    - when mouse events are received the blank card will be shown
    - when focus is lost the blank card will be shown
    This way the applet (which will fill the browser) will have to be focused (and ready to get input events) for the image to be displayed. If the user tries to do a screenshot using the keys or the mouse the blank card will be shown.
    Comments?

    It can't be done. What you're proposing is what's known as a "trusted client solution" (google it). Basically you're relying on your applet (which runs on the client's machine) to disallow certain behaviour (i.e. copying of the image). Problem is, once the image has been transferred to the client's machine, all bets are off - there are a billion ways to circumvent any security you come up with on the client side.
    How about watermarking the images in question? It won't stop people from stealing them, but it would make it easier to track down infringers by providing you with a mechanism to prove that the images were stolen from you.

  • I am using the Adobe Acrobat Reader on a mac and I followed all the directions to copy an image but when I press paste only half of the image appears or it appears as an empty square. What can I do to fix this?

    I am using the Adobe Acrobat Reader on a mac and I followed all the directions to copy an image but when I press paste only half of the image appears or it appears as an empty square. What can I do to fix this?

    Hello,
    I would like to inform you that not all the browsers and online PDF readers support copying text from a PDF. If you have opened the PDF online, please download PDF file to your computer and then open the file in Adobe Reader.
    Please share a screenshot if the issue still persists.
    Regards,
    Nakul

  • How to Copy an Image File from a Folder to another Folder

    i face the problem of copying an image file from a folder to another folder by coding. i not really know which method to use so i need some reference about it. hope to get reply soon, thx :)

    Try this code. Make an object of this class and call
    copyTo method.
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class FileUtil
    extends File {
    public FileUtil(String pathname) throws
    NullPointerException {
    super(pathname);
    public void copyTo(File dest) throws Exception {
    File parent = dest.getParentFile();
    parent.mkdirs();
    FileInputStream in = new FileInputStream(this); //
    Open the source file
    FileOutputStream out = new FileOutputStream(dest); //
    Open the destination file
    byte[] buffer = new byte[4096]; // Create an input
    buffer
    int bytes_read;
    while ( (bytes_read = in.read(buffer)) != -1) { //
    Keep reading until the end
    out.write(buffer, 0, bytes_read);
    in.close(); // Close the file
    out.close(); // Close the file
    This is poor object-oriented design. Use derivation only when you have to override methods -- this is just
    a static utility method hiding here.

  • Problem with display of images in applets

    Hi all,
    When I run this program, the appletviewer window is showing no output (i.e. no image). I'm using the netbeans IDE 5.0.
    Blue hills.jpg is present in both the src folder and build folder.
    * <applet code="image" width =800 height=600>
    * <param name="img" value="Blue hills.jpg">
    * <\applet>
    import java.awt.*;
    import java.applet.*;
    public class image extends Applet {
    Image img;
    public void init() {
    img=getImage(getDocumentBase(), getParameter("img"));
    public void paint(Graphics g){
    g.drawImage(img,0,0,this);
    Please help in figuring out the problem....

    It will be looking for it in the folder with the HTML that invokes the applet.
    If you want to pack the image in with the applet then use getResource instead.
    And spaces in the name are probably not the best idea.

  • How do I copy an image from one Keynote presentation to another one?

    I have a previously saved presentation on Keynote in iCloud. I created it from my desktop at work. Some of the images I used for the presentation I want to use again in another presentation, onlh this time I am working off my laptop and don't have the same access to those images. Is it possible to copy/paste images from one Keynote presentation into another? I can't even seem to click on the image and save it.
    Any suggestions?

    Clicking and dragging does not work.
    Click on the image and Copy and Paste
    or
    Inspector > Metrics > File Info > click on the icon of the file and drag it to your desktop
    You can then drag that file back in wherever you want.
    Peter

  • Apex 3.1 upgrade on 11g - Where do I copy the images to?

    Hi Everyone,
    I've just installed Oracle 11g Personal Edition on my laptop, I have successfully configured Apex 3.0 and am now trying to finish off the upgrade to 3.1
    (We are unable to upgrade to 3.1.2 yet, however this is scheduled for early in the new year - until this time we must continue to use 3.1)
    I have run the install/upgrade to 3.1 successfully and have enabled the network services in 11g.
    However I am getting stuck on copying the images over,
    the documentation it says to copy into the ORACLE_HTTPSERVER_HOME\ohs\images directory
    I cant find where my ORACLE_HTTPSERVER_HOME is set - can anyone please help to point me in the right direction
    I have tried to search for the folder ohs on my hard drive, but can only find a folder called ohs_images
    (C:\app\oracle\product\11.1.0\db_1\oc4j\j2ee\home\default-web-app\ohs_images)
    Thanks in advance for your help.
    Kind Regards, Michelle

    Hi Varad,
    Thanks for your prompt response.
    I have run the apsldiimg.sql script to update the images directory - however it still does not seem to want to work for me! :)
    When I run the script in SQL*Plus I get the following results
    SQL> @apxldimg.sql C:/ApexUpgrade
    PL/SQL procedure successfully completed.
    old 1: create directory APEX_IMAGES as '&1/apex/images'
    new 1: create directory APEX_IMAGES as 'C:/ApexUpgrade/apex/images'
    Directory created.
    PL/SQL procedure successfully completed.
    Commit complete.
    timing for: Load Images
    Elapsed: 00:02:35.39
    Directory dropped.
    SQL>
    When I go to logon to Apex, either in the Admin or Workspace areas I am unable to login.
    The page displays but the normal login images aren't displayed.
    Thanks, Michelle

  • Cannot Copy RAW Images to Tiff or Jpeg while in ACR

    Requesting immediate help if anyone available currently
    I've been using Photoshop CS6 for several years, never a problem at all. As soon as I bought Creative Cloud, I see many issues that cannot be resolved or are recurring.
    Again today as I go to copy files (images) from Adobe Camera Raw, to say a Tiff or a Jpeg, it appears to begin to copy as normal, then suddenly a box appears with all my copying
    file name/numbers, and it begins to eliminate one by one "Cannot Create File", failing the entire process to copy. I have never seen this until I began using Creative Cloud about a
    month ago.
    Can anyone help this Saturday evening as I am trying to complete a large project of images for others who expect them soon?
    Thank you and I look forward to any advice soon,
    Mark Seibold, Artist-Astronomer, Portland Oregon

    First I'd like to state I am fairly ignorant of Adobe Camera Raw, as I've been using Lightroom for years. I'm only replying because you seem under a close time constraint.
    Are you working within PS CC? It seems that Camera Raw no longer exists independently, but rather as a plug in within PS CC. I mention this because I seem to recall at one point it could function as an independent app. I am just wondering if you were using an old version of ACR, that may have been overwritten, or started within PS CC.
    That is the only help I can offer as far as ACR, and may have nothing to do with your issue.
    If you must get these done very soon and can't solve ACR, I'd also suggest giving Lightroom a shot, if you've access to it, just this one time, until you get ACR running again. Open it up, Create an intial library, like 2015 or Lightroom. Import the images you'd like to copy/convert, in a way that that the originals aren't moved and copies of the RAWs, (or DNGs) are made. Then select all, in the most recent import folder, and turn around and export them in whatever form you desire. Also, Lightroom is non-destructive, so, if you'd like to try making adjustments before exporting, under the develop tab, any alterations or adjustments you might make before exporting are completely reversible.
    I realize changing one's workflow, and learning a new app, may be too much effort at this point, and very possibly require too much time, but you might pick it up quickly enough to get 'er done on time.
    That is all the help I can offer. Wish I knew more about ACR.

  • Cannot copy RAW images to Tiff or Jpeg in ACR

    Requesting immediate help if anyone available currently
    I've been using Photoshop CS6 for several years, never a problem at all. As soon as I bought Creative Cloud, I see many issues that cannot be resolved or are recurring.
    Again today as I go to copy files (images) from Adobe Camera Raw, to say a Tiff or a Jpeg, it appears to begin to copy as normal, then suddenly a box appears with all my copying
    file name/numbers, and it begins to eliminate one by one "Cannot Create File", failing the entire process to copy. I have never seen this until I began using Creative Cloud about a
    month ago.
    Can anyone help this Saturday evening as i am trying to complete a large project of images for others who expect them soon.?
    Thank you and I look forward to any advice soon,
    Mark Seibold, Artist-Astronomer, Portland Oregon

    Hi Rick
    Thanks for clarifying that. Yes, that term was my mistake, as I meant to write 'Save As"
    Another forum respondent just replied also, and he states as so many others do, that they do not use
    the Adobe Camera Raw app formerly with CS6, as they instead use Lightroom, so he apologized that he
    was not familiar with ACR but that I might have an old CS6 plug-in running that may not be completely
    compatible with the new Creative Cloud. I am not sure if this is the problem.
    What I would find as not really likely, is that the Creative Cloud engineers would go through all the trouble
    to redesign from the old CS6, then even assist us over the phone to help install it, but in oversight,
    leave us without a proper update to properly run Adobe Camera Raw. I also have never really understood the advantage of Lightroom. I'm sure that many must enjoy its efficiency, as I hear wedding photographers like it for huge batch processing of adjusting many images in synchronicity all at once. I would say that I do the same with ACR accessing it through Bridge, and I like ACR's quick and simple access for simple image adjustments and then say a small batch all synchronized, then finally to "Save As" for all selected to a final output as Tiff or Jpeg.
    As an astronomer that has just started learning to use Registax for night sky images, we also like the ACR adjustments and then to "Save As" eg. all Jpeg or all Tiff, to then photo-stitch large landscape and night sky panoramas with Microsoft ICE photo-stitching.
    Sorry for the long description here, but I hope to relate the total idea of what I am doing for the past years. I'll even attach an example >
    Thanks for your possible solution to my problem in "Saving As" in ACR,
    Mark

  • I am trying to find out how to copy the image on my existing hard drive to my new hard drive before I install it so it will be like I didn't do anything.

    I am trying to find out how to copy the image on my existing hard drive to my new hard drive before I install it so it will be like I didn't do anything. Thanks for the info. on changing it.

    Format is found in the Erase Tab:
    The Disk Image is found on the Restore Tab:

Maybe you are looking for

  • Lion and Multi-Display (2 external monitors + built-in Display) [Thunderbolt, USB adapters/eVGA UV+]

    Hi everyone, I just completed an upgrade to Lion and while I love it I've suddenly found myself short 1 display. I use 2x24" with my MacBook Pro - 1 via mini Display Port [the Thunderbolt port] and another via an eVGA UV+ [both displays have a resolu

  • Menu options not working in web reports

    Hai,      I made a template in WAD based on a query view. When I publish, none of the options in the menu, that appears when I right click on the characteric object, "Keep filter value, select filter value, remove drill down" etc. allof them doesn't

  • Strange font situation in Keynote

    I just upgraded to Yosemite and the latest version of keynote. I opened a presentation I previously created in the last version of Keynote and a weird thing is happening with fonts not appearing correctly. I attached 2 screenshots to illustrate what'

  • Mail notification from DDMI 9.31

    Dear Expert, I want to know in DDMI the mail notification is generating or not? I mean to say that if any changes done in our environment (lets say memory size increases) then after monitoring the mail notification would be triggered or not, if yes t

  • Cheque Deposit And BRS

    To SAP Guru's, I have a problem regarding Cheque deposit configuration Can any body explain me cheque received with clearing and cheque received without clearing with accounting effect what posting type selected while we preparing posting rule for bo