Capturing an image of a component?

Hi, I hava a custom jComponent (an animated circle, which is a hyperlink button).
I want to move this component across the sceen or get it to a buffered image.
I have no problem in making the graphic move across the screen, my problem seems to be capturing the actuall component.
I have tried the following code:
int wid = jButton1.getWidth();
       int hie = jButton1.getHeight();
       bi = new BufferedImage(wid, hie, BufferedImage.TYPE_INT_ARGB);
      big = bi.createGraphics();
       Image imi = null;
       imi = jButton1.createImage(wid, hie);
       if (imi == null) {
         int imi2 = wid;
       big.drawImage(imi, 0,0,this);
offGraphics.drawImage(bi, 50,50, this);When this code run's in the update() mehtod, it shows nothing.
If I replace the big.drawimage, with something like big.drawLine, it works fine.
does anybody have any clues?
Cheers!

ok, I sorted it out, here is the correct code:
Component c = jtaButton1;
    int w = c.getWidth();
        int h = c.getHeight();
        bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        big = bi.createGraphics();
        c.paint(big);
        big.dispose();now the strange thing is that the original component is flashing and the copy isn't. Now I presume that this has something to do with sync, becuase the component itself is runnig as an animation with an update thread, and the panel it's in is animated with it's own thread. So I would presume that they are running out of sync.
Any suggestions on how to get them in sync would be great?
Currently I have worked around it by repainting the bufferedimage over the top of the original component.
Cheers

Similar Messages

  • Capturing the apperance of a component before it gets visible and laid out

    Basically, I'm trying to make components fade in. My strategy is to create a BufferedImage instance, and have the component paint on this image (aComponent.paint(img.getGraphics()). When I have the BufferImage, I can easily use Java2D to make the image fade in, by blending it with the background. When the image is fully shown, I simply show the real component instead of the faux image.
    This all works fine, if the component has already been shown, and I want to capture an image of the component and fade it out. The problem is, when the component has never been shown (and been laid out by the layout manager), all I get is a gray image. I have been trying various things, like calling aComponent.doLayout(), and then I usually do get a few of the sub-components painted (that in turn make up the component I'm referring to), but not all of them, and the layout seems wrong. For example, a left-aligned text field (again, part of the component I'm trying to fade in) might appear as it should, whereas a layout-sensitive component such as a JEditorPane will not have gotten its proper size, and other sub-components still will not even be present.
    Are there are Swing gurus present that can help me sort this out?

    Thanks for all your suggestions. Actually, I'm not only trying to fade the component in, I'm also rolling it up and down. The code I'm working with is based on Fr�d�ric Lavigne Apache-licensed JTaskPane (http://common.l2fprod.com/), which supports expanding and contracting an image of a component.
    Basically, the way JTaskPane works (and more specifically, the JCollapsiblePane it uses), is that an image is taken of the component when JTaskPane is initialized. This all works fine when the JTaskPane is initially expanded (that is, the real component is shown), but my application requires that initially, the component is not shown. I have attempted to patch Fr�d�ric Lavigne's code so that the image is taken right before it is to be shown, but I still only get a gray image.
    I have had limited success using SwingUtilities.invokeLater() -- but my component is not fully laid out even when I capture the image in the run() method of the object instance I pass to invokeLater() (specifically, the JEditorPane that is placed on my component, is not yet laid out, but the JTextFields are). Curiously enough, if I use a javax.swing.Timer, I manage to capture the fully laid out image just fine, but I would prefer using a more elegant solution.
    All suggestions are most appreciated.

  • Need to capture multiple image paths for responsive design when only one will be displayed at a time

    I'm new to CQ and am having enough trouble following the documentation on image components as it is (why is there no master reference for all this?). I have a requirement where we need to capture three versions of an image and put the URLs into three attributes of a tag. The appropriately sized image will be selected via JavaScript based on the browser/device capabilities. I need to know how to capture those images when seemingly only one at a time can be dropped onto the page. Or perhaps there is a more CQ solution to this.

    Hi,
    You need to customize image component. I mean selected image is a asset in the repository and each asset by default has 3 rendtion generated when the image is uploaded in the dam.
    For example when you upload image.jpg file into the DAM, standard workflow is launched and after a while inside the repository (see paths) are created following renditions:
    /content/dam/project/image/image.jpg/jcr:content/renditions/cq5dam.thumbnail.140.100.png
    /content/dam/project/image/image.jpg/jcr:content/renditions/cq5dam.thumbnail.319.319.png
    /content/dam/project/image/image.jpg/jcr:content/renditions/cq5dam.thumbnail.48.48.png
    This process can be customized by changing /etc/workflow/models/dam/update_asset.html workflow and modifing "Thumbnail creation" step by adding in the Process tab -> Arguments field new values for new rendition. So for example if you add there [400,400] new rendition will be created in the path
    /content/dam/project/image/image.jpg/jcr:content/renditions/cq5dam.thumbnail.400.400.png
    Next step is to customize jsp for image component. Using path to the drag and dropped image from a component attributes you can easily take all renditions iterating on the /content/dam/project/image/yourimage.jpg/jcr:content/renditions node and then set paths to all renditions in the tag attributes. Then like you wrote using js you can select proper rendition.
    I hope that it hepls you.
    Regards,
    Adam

  • How to capturing scrolling images with no java controls?

    Can somebody help me? I am trying to capture the image of the browser, using the followed code to do it, but I can not take it scrolling the screen. I do not use any control of java in the browser. Does anybody have an idea?
    Robot r = new Robot();
    image1 = r.createScreenCapture(clippedScreen);
    File file = new File("c:\\Csa\\3.9\\Fimages\\"+counter+".jpg");
    javax.imageio.ImageIO.createImageOutputStream(file);
    ImageIO.write(image1,"jpg",file);
    //Scroll the screen
    scrollTheScreen ();
    //Takes scrolled area
    image2 = r.createScreenCapture(new Rectangle(0,666,1280,80));
    File file2 = new File("c:\\Csa\\3.9\\Fimages\\"+counter+1+".jpg");
    javax.imageio.ImageIO.createImageOutputStream(file2);
    ImageIO.write(image2,"jpg",file2);
    As you can see I take two parts of the screen but I am having troubles adding the images, I do not know if there is an easier way to do this.
    Thank you in advance.

    Thanks to anybody, but i found the way on how to capture the image.
    1. Take a snapshot of the screen.
    2. Scroll the screen pushing the button down.
    3. Take the snapshot of the scrolled part of the screen.
    4. Scroll the screen pushing the button down.
    5. Take the snapshot of the scrolled part of the screen.
    6. Compare the 2 last images, if they are equals, stop scrolling, else scroll again.
    7. Join the images first, second and third images, to get a single one corresponding to the hole info of the browser.
    8. Save the resulting image.
    The thing in this problem is to manage the images as RGB components for that you must use the getPixel(col, row, color); method to manipulate the components in matrix and added to a bigger matrix where you join the complete components. Be sure that you manage the 3D matrix correctly, [width of the screen] [height of the screen] [RGB components], i.e.
    * This saves just the red component, the green and blue must be saved too.
    public int[][] imreadRed(BufferedImage bi)
              Raster r = null;     // * Raster
              int [][] image;     // * Image array
              int imageWidth = bi.getWidth();     // * Image Width
              int imageHeight = bi.getHeight();     // * Image Height
              int[] color = new int[3];     // * array to colors RGB (r -> 0, g -> 1, b -> 2)
              r = bi.getData();
              image = new int[imageHeight][imageWidth];
              for(int row = 0; row < imageHeight; row++)
                   for(int col = 0; col < imageWidth; col++)
                        r.getPixel(col, row, color);
                        image[row][col] = color[0];          //Saves the red color to the array image on the first coordinate
              return image;     //Return the array with the red component
         }* This merge the matrix into a bigger one.
    public int [][] mergeMatrix (int [][] mat1, int [][] mat2){
             int rowsMat1 = (mat1.length-53), colsMat1 = mat1[0].length,     //mat1.length da los renglones de la matriz height  
             rowsMat2 = mat2.length, colsMat2 = mat2[0].length;          //mat1[0].length da las columnas de la matriz width
             int [][] addedMatrix = new int [rowsMat1+rowsMat2][colsMat1];
             for (int row = 0; row < rowsMat1; row++) {
                  for (int col = 0; col < colsMat1; col++) {
                       addedMatrix [row] [col] = mat1 [row] [col];
              for (int row=0; row < rowsMat2; row++) {
                   for (int col = 0; col < colsMat2; col++) {
                        addedMatrix [rowsMat1+row] [col]  = mat2 [row] [col];
             return addedMatrix;
        }* This convert the matrix into an image.
    public BufferedImage imwriteComponents (int [][] arrRedImg, int [][] arrGreenImg, int [][] arrBlueImg) {
              int arrayWidth = arrRedImg[0].length;     // * Image Width
              int arrayHeight = arrRedImg.length;     // * Image Height
              BufferedImage completeImage = new BufferedImage(arrayWidth, arrayHeight, BufferedImage.TYPE_INT_RGB);     // Create a BufferedImage with RGB pixels
              WritableRaster wRaster = completeImage.getRaster();     // Create a raster so we can access the BufferedImage pixels
              int [] color = new int [3];     //color variable to save all the components
              //join the 3 matrix in one color type
              for(int row = 0; row < arrayHeight; row++)
                   for(int col = 0; col < arrayWidth; col++) {
                        color [0] = arrRedImg [row][col];
                        color [1] = arrGreenImg [row][col];
                        color [2] = arrBlueImg [row][col];
                        wRaster.setPixel(col, row, color);
              return completeImage;     //Return the Buffered image with the red array component
        }That is a solution that I found to this problem, if someone has an easy way to do it please tell us.
    Thank you.

  • "Unable to capture window image"

    if I select a window to be screenshot, I get this error:
    Your screen shot can’t be saved.
    Unable to capture window image.
    (shortcut: cmd-shift-4 and then space)
    It seems to be new in Lion. Never had that problem before. And regular screenshots seem to work fine (cmd-shift-3).
    Thanks for any help! ~ Kai

    Thanks Davide ...
    I created com.apple.screencapture.plist with Terminal and restarted the Mac.
    The first couple of window screenshots worked on a Chrome browser window (command-shift-4, then space bar). But it did not work on other app's windows (Finder, Carousel).
    Then I switched back to Chrome and I didn't work there too anymore. Crazy thing is that now it works on Finder windows. Very very strange.
    All this is only true for capturing a whole window content (command-shift-4, then space bar)
    ~ Kai

  • Camera - Torch 9800 - Unable to capture the image

    Hey everyone!
    Had a torch 9800 for 18 months now and always been working fine... until today.
    I went to use the camera and it all seemed to open up fine but instead of seeing what the lens sees the screen was black. The centre focus [ ] was there and I could zoom back and forth just a black screen. 
    When I click for a photo I get a message " Unable to capture the image "
    I have searched the web and found nothing conclusive. Battery pulls, a full wipe and installation of the o/s have made no difference to it's lack of function.
    Does anyone out there have a suggestion? 

    I am having the exact same issue.  I also tried rebooting, taking out the battery and sim card and cleaning out the back, alas no difference.

  • Deployment Workbench - how to capture an image after customisation?

    I have deployed Vista to a machine using WinPE (Created through Workbench) and chose the option when deploying "Prepare for capture"
    I then customised Vista - in this case removing the Fax applications and ran Sysprep with OOBE, Generalise and Shutdown.
    In workbench I created a new task sequence 'Standard Client Replace task sequence' which seems to be the right task to capture an image.
    When selecting the task when booting the machine with WinPE, it forces me to capture the user data - I cannot select 'Do not save data and settings'
    I must be doing something wrong!
    What I want to do is:
    Deploy Vista
    Install some apps manually i.e. not using a task sequence
    Capture the image
    Deploy to machines
    How can I do this using Workbench? Thanks.

    Hi,
    Thank you for the reply.
    I suggest referring to the following article:
    Creating a Computer Image
    http://technet.microsoft.com/en-us/library/bb977918.aspx
    If you select “Capture an image of this reference computer” on the “Specify whether to capture an image” page when running Deployment Wizard, it will sysprep and capture the system for you automatically.
    If you would like to
    “Install Vista and prepare for capture
    Install my own applications WITHOUT using task sequences
    Capture the OS”,
    I am afraid that you do not need to use MDT (you cannot perform a LTI without running Task Sequences). You can do this by only using WDS.
    1.   Install and configure the WDS Server.
    2.   Add the default Windows Server 2008 boot image to the WDS Server.
    3.   Create Capture Boot Image and add it to boot image in WDS Server.
    4.  Create a reference computer (install the operating system, applications, and make any other changes)
    5.  Sysprep.
    6.  PXE boot the reference computer into capture image on the boot screen and then capture the image (If non-PXE supported, make a discover image to boot)
    7.  Upload the captured image to WDS server.
    8.  Clients can PXE boot and install Windows (If non-PXE supported, use a discover image to boot).
    Hope it helps.
    Tim Quan - MSFT

  • How to capture an image from a clip

    Hi,
    Is there a way to capture an image from a movie clip using iMovie 06?
    I would like to save some frames from the vedio footage as photos.
    Any help will be greatly appreciated. Thank you.
    New Mac User
      Mac OS X (10.4.5)  

    Hi iMac User:
    Yes-you can save a single frame from iMovie by selecting the File-->Save Frame As option. From there it will ask you where and in what format you want to save it.
    Just be aware that the quality won't be perfect because it is taken from a video clip.
    Sue

  • How to capture an image and save it using action script

    Hello,
    I need to know if is posible to capture an image or a screen region and save it using action scrip.
    Somebody know how to do it ??
    Thanks

    you can capture an image using the bitmapdata class and getPixel().  you can then save that to a bitmap using server-side code like php.

  • How to capture an image from my usb camera and display on my front panel

    How to capture an image from my usb camera and display on my front panel

    Install NI Vision Acquisition Software and NI IMAQ for USB and open an example.
    Christian

  • Capture an image using the web camera from a web application

    Hi All,
    Could anyone please share the steps what have to be followed for capture an image using the web camera from a web application.
    I have a similar requirement like this,
    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.
    3) Upload the Image to the server from the temporary location.
    Please share the details like, what can be used and how it can be used etc...
    Thanks,
    Suman

    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)There's not really any good way to do this with JMF. You'd have to somehow create a JMF web-start application that will install the native JMF binaries, and then kick off the capture device scanning code from the application, and then scan through the list of devices found to get the MediaLocator of the web cam.
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.You'd probably be displaying a "preview" window and then you'd just want to capture the image. There are a handful of ways you could capture the image, but it really depends on your situation.
    3) Upload the Image to the server from the temporary location.You can find out how to do this on google.
    All things told, this application is probably more suited to be a FMJ (Freedom for Media in Java) application than a JMF application. JMF relies on native code to capture from the web cams, whereas FMJ does not.
    Alternately, you might want to look into Adobe Flex for this particular application.

  • How to capture an image with the camera axis

    Hi,
    I have an camera axis. I can receive the video. Now I try to capture an image, for example when I push the button take. I do the .vi but I confused between the different Method.
    SaveCurrentImageave the current Image
    GetImage:Gets the data corresponding to the image currently being
    displayed.SetImage:Adds an Image to the Clipboard in the Bitmap format
    That I search is to know if to capture image and saving when I push an button  I need to put all Icons so SetImage after Getimage and SavecurrentImage.
    I put my .vi.  
    Attachments:
    Capture_image.vi ‏11 KB

    Hello,
    Did you download the kit sdkfor using the axis media control active X:
    http://www.axis.com/fr/techsup/cam_servers/dev/activex.htm
    Did you test the sample and did you test with another language?
    Regards,
    Nacer M. | Certified LabVIEW Architecte

  • Capturing an image to use for PXE boot

    I'm using Windows Deployment Services in conjunction with Windows Deployment Terminal (Windows Server 2008) to capture an image from one of our workstations to use as a PXE boot image for future computers. I've created the capture image and PXE booted
    to that image, which brings up the "Image Capture" wizard. After capturing the image, I created an install image in WDS using the same .wim file. After trying to PXE boot, the workstation yet again brings up the "Image Capture" wizard.
    I then right clicked the image under Boot Images (in WDS) and selected "Create Discover Boot Image." A loading window pops up, but always ends with an error saying something to the extent of the image doesn't have WDSClient Binaries. Does anyone
    know what this is or how to fix this? Or even if I'm going about it the right way? If anyone has any advice, I'd appreciate it.

    Hi,
    Yes, you can.
    Here are the rough steps:
    1. 
    Install and configure the WDS Server.
    2. 
    Add the Windows 7 boot image to WDS.
    3. 
    Create a Capture Boot Image and add it to Boot Image.
    4. 
    Create a reference Windows 7 computer (install Windows 7, Office and other applications as you like)
    5. 
    Sysprep the Windows 7 computer.
    6. 
    PXE boot the reference Windows 7 computer into capture image on the boot screen and then capture the image.
    7. 
    Upload the captured image to WDS server.
    8. 
    PXE boot clients, choose the captured image to install the system.
    Please refer to this link
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/be3af7db-b71b-4b14-b166-fef83cde0ac6/deploy-windows-7-from-waik-with-some-application-added?forum=winserversetup
    I had the similar problem couple of years back
    UMESH DEUJA MCP,MCTS,MCSA,CCNA

  • When I am trying to package my artwork in Adobe Illustrator CC, it is not capturing my images and fonts. How do I make sure my linked photos and fonts are captured?

    When I am trying to package my artwork in Adobe Illustrator CC, it is not capturing my images and fonts. How do I make sure my linked photos and fonts are captured?

    Not all fonts can be packaged depending on their licensing. Some fonts are set to not allow packaging. For those you would have to manually locate them on your computer and add them to the folder where the packaging occurred.
    For the images have you checked the "copy links" option?

  • How to change the path of sysprep files that were copied to reference computer when i capture the image from reference.

    Dears ,,
    how to change the path that sysprep were copied to reference computer when i capture the image from reference.
    Should i modify some codes in LTIAPPLY.wsf? how to modify it?
    Thanks.

    Sysprep and capture has *Three* steps.
    1. Run sysprep on the local machine (easy).
    2. Copy WinPE down to the local machine so we can reboot into winpe for capture.
    3. Capture the drive in an *offline* state from within WinPE.
    What is most likely happening is that you are having problems with step #2. 100MB is *WAY* too small to copy down WinPE. By default MDT will make this System partition much bigger, 499MB. IF you install Windows 7 from the default media. IT will only create
    a 100MB partition.
    By default MDT 2012 Update 1 and greater *should* recover to a fallback drive with the OS on it, however if you are running older versions that might not happen correctly.
    If you are still having problems, copy your BDD.log file to a public share like OneDrive and copy the link here.
    Keith Garner - keithga.wordpress.com

Maybe you are looking for

  • Windows 8 Pro running very slow after upgrade

    Hi,      I ve just upgraded to windows 8 Pro (64-bit) from Windows 7 Pro (64-bit) on macbook pro retina 15 but windows 8 is running very slow on my MBP whereas windows 7 was lightning fast. Now in windows 8 i have to wait till my app is active for cl

  • Why is my track pad becoming unresponsive

    Loaned Mountain Lion on the releasse day.  All was well then suddenly my track pad is unresponsive when using Chrome.

  • Password protected folder???

    Is there any way to require an administrator password to open a folder?

  • Walled Garden Functionality

    We have 18 controllers running 4.2.176.0. We have a captive portal page for our guest access WLAN using web passthrough. We have a custom Accept Page. Our legaleese on that page is sooooooo long that I want to know if we can simply place a URL on our

  • Most photos do not email or are empty when dragged to folder

    After I edit my photos in iphoto and email them to myself, usually large quantities, (50plus) at one time, only 2 actually emailed. Although my email said that 50 were successfully sent. I do large quantites at a time because I have shops on Etsy tha