How to convert BufferedImage back to Image

I have an Image from ImageIcon and i want to cut it using BufferedImage.getSubImage(...) and now from BufferedImage i want to turn it to Image again so that i can put in ImageIcon.
Here is my code:
URL img = new URL(location);
ImageIcon imgIcon = new ImageIcon(img);
Image image = imgIcon.getImage();
//turn image into bufferedImage via graphic draw
BufferedImage bi = new BufferedImage(..);
Graphics g = bi.createGraphics();
g.drawImage(image,0,0,null);
bi.getSubImage(...);
// how to turn bi back to Image newImage
any ideas??

More correctly, BufferedImage extends Image as Image is an abstract class and not an interface.
Shaun

Similar Messages

  • How to convert Doc file into image

    hello frnds
                     Can any body guide me how to convert doc file into image and show into swf loader.
    actually i have to convert doc files into swf files in runtime so that i have to use this flow.
    is it possible to convert doc file into byte array and than convert into image.
    Thanks And Regards
        Vineet Osho

    You can convert any DisplayObject to byeArray using this function ImageSnapshot.captureBitmapData().getPixels()

  • How to convert a 16-bit image to 8-bit

    I am having difficulties in skeletonizing my image. Although I already threshold my image, it still cannot be skeletonized. When I create the image using IMAQ create, the image type must be set to 16-bit, otherwise it will create an error message. An enthusiast in the forum told me that the image must be 8-bit so that it can be skeletonized. But I do not know how to convert the image from 16-bit to 8-bit. So is there anybody out there that can provide me with a solution. Attached is the VI that I used. Really appreciate your help.
    Attachments:
    Image_Acquisition.vi ‏68 KB

    Try using the IMAQ Cast Image function under Motion & Vision>>Vision Utilities>>Image Management>>IMAQ Cast Image.
    Regards,
    Steve

  • How to convert a folder of images to a Collection?

    Ques 1
    How do I convert a folder of images that has been sorted, files rejected, files hidden, and so on, to a Collection? When I create a New Collection and drag the images across from the folder, all editing is lost and the images appear in alphabetical order. I'm using CS6.
    Ques 2
    What is the location of the file that contains the sorted/rejected/hidden data for a folder?

    A Collection is just a saved search.  It does not contain any images.
    Wonder why your question went unanswered for so long?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    A screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • How to convert HTML text to image

    Hi all!
    I´m having this problem: I have a html code (dynamic generated) and I need to convert it to a image, any idea how to do that?
    Thanks, J.

    Im no Java2D expert but if you want the actual code as an image couldnt you just use 'drawString("<br>", x, y)' to display it and then allow it to be saved as an image, I know theres built in capability in Java to import/export common image formats. Or do you mean you want what the html actually produces as an image?
    Ken

  • How to convert surround back to stereo?

    I've got into a problem with surround sound. One track from the loops library is in surround format and this seems to make it impossible to insert mastering fx in the normal way on the Out 1&2 tracks? (The insert slots have simply disappeared.)
    Can anyone enlighten? How does a surround sound get converted back to normal stereo, and how do i go about restoring the insert slots to the out 1&2?
    Thankz ahead,
    Byz

    More correctly, BufferedImage extends Image as Image is an abstract class and not an interface.
    Shaun

  • How to convert color of bitmap image?

    I am programming with Acrobat 7.
    I'd like to change color of all object to CMYK color or gray.
    In case of plain object like path or font,
    I need to seek CMYK color from the object's RGB color.
    and I change the property of the object color space and value with it.
    but in case of bitmap image, i don't know how to at all.
    it has numerous colors.
    I hope your advice.

    Thank you both of you.
    by the way, Leonard, Could you tell me that APIs more detailly?
    I have look into the document for long time. it is still hard to find proper API.
    I have to say this again. I am trying to find APIs based on version 7.
    I am using custom function ACEconvertColorProfile which is placed in snippetrunner. it consists of these APIS ACMakeColorTransform, ACApplyTransform, and so on.
    but I can't find the way to convert bitmaps once and for all.
    I hope you give more hint.
    Thanks again.

  • How to convert read-only disk image to read/write disk image?

    There was some problem with the Mavericks firmware and i keep getting the "white screen of death". I tried the method of backing up Macintosh HD to an external drive via Disk Utility. The problem is I saved it as a compressed file (read-only). I wasn't aware of the problem and went ahead and delete the original Macintosh HD files and set up everything fresh.
    Then when i wanted to back up all my old files from Macintosh HD disk image back up that i created, i can't because the dmg is read-only. I tried to convert it to read/write with disk utility but it couldn't.
    Is there another way to extract the videos and photos? That's all i need.

    A blank empty read only disk image has never been possible. If it's read-only, it cannot be modified, and so it would be blank and empty forever. Not much point in that.
    If you want read-only and encryption on your finished disk image, you'll have to put your files into a folder, and then do File -> New -> Disk image from folder.

  • How to convert simple text to image

    Hi,
    I needed to secure web form from automated form submission. Looking into some common website, they use image displaying random text, which is only readable by user. So the automated form submission can be avoided.
    I checked through lot of forum, but could not find help in doing it using java. So is there something in java api using which i can generate image of fly for each request by passing some random generated text of about 5-6 character length.
    Any help on this would be appreciated...
    Thanks,
    Naresh

    hi ican convert image ti html
    coding---------------
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import java.awt.event.*;
    public class img2html extends Frame
         static Image im=null;
         static int W=-1,H=-1;
         public img2html()     {}
         public static void main(String args[])
              String infile,outfile;
              infile="c:\\micky.jpg";
              outfile="c:\\micky.html";
              boolean paramsOK=false,mode=false;
              //if (args.length <= 1) {
              //     usage();
              //     paramsOK=false;
         //     if (args.length == 2) {
              //     infile = args[0];
              //     outfile = args[1];
                   paramsOK=true;
              if (paramsOK) {
                   //System.out.println("img2html :");
                   System.out.println(" image file " + infile);
                   System.out.println(" data file " + outfile);
                   img2html widow = new img2html();
                   System.out.println("img2html : Loading image file");
                   if (widow.processFile(infile)==false) {
                        System.exit(0);
                   //System.out.println("img2html : Saving data file");
                   saveByteData(outfile,mode);
                   System.exit(0);
         public static void saveByteData(String fn,boolean i)
              int[] grabMapXY;
              grabMapXY          =      new int[(W * H)];
              int pix;
              PixelGrabber pg = new PixelGrabber(im,0,0,W,H,grabMapXY,0,W);                
    //     PixelGrabber pg =
    // new PixelGrabber(image, 0, 0, -1, -1, false);
              // start grab
              try {
                   pg.grabPixels();
              } catch (InterruptedException e) {
                   System.out.println("Map grab failed : " + e);
                   return;
              if ((pg.status() & ImageObserver.ABORT) != 0) {
                   System.out.println("Map grab failed !");
                   return;
              // need to base r on number of valid pixels
              writeToFn(fn,"<HTML>");
              writeToFn(fn,"");
              writeToFn(fn,"<BODY>");
              writeToFn(fn,"");
              writeToFn(fn,"<TABLE border=0 cellspacing=0 cellpadding=0>");
              int red,green,blue,p;
              String r,g,b;
              Color c;
              for (int y =0; y < H; y++) {     
                   writeToFn(fn," <TR>");
                   for (int x =0; x < W; x++) {
                        pix=grabMapXY[ y * W + x ];
                        c = new Color(pix);
                        red=c.getRed();
                        blue=c.getBlue();
                        green=c.getGreen();
                        r=Integer.toHexString(red);
                        g=Integer.toHexString(green);
                        b=Integer.toHexString(blue);
                        if (r.length()==1) { r="0"+r; }
                        if (g.length()==1) { g="0"+g; }
                        if (b.length()==1) { b="0"+b; }
                        writeToFn(fn," <TD WIDTH=1 HEIGHT=1 BGCOLOR=#" + r + g + b + ">", " " + x + "," + y + " - of - " + W + "," + H);
                        writeToFn(fn," </TD>");
                   writeToFn(fn," </TR>");
              writeToFn(fn,"");
              writeToFn(fn,"</TABLE>");
              writeToFn(fn,"");
              writeToFn(fn,"</BODY>");
              writeToFn(fn,"</HTML>");
         public static void writeToFn(String fn,String Dbytes,String status) {
              try {
                   //System.out.println(Dbytes + " pixel " + status);
                   DataOutputStream dos = new DataOutputStream( new FileOutputStream(fn,true));
                   dos.writeBytes(Dbytes); //
                   dos.writeByte(13); // line feed for each line
              dos.writeByte(10); // line feed for each line
                   // close here
                   dos.close();
              } catch (IOException e) {
                   System.err.println("File error: " + e.getMessage());
         public static void writeToFn(String fn,String Dbytes) {
              try {
                   //System.out.println(Dbytes );
                   DataOutputStream dos = new DataOutputStream( new FileOutputStream(fn,true));
                   dos.writeBytes(Dbytes); //
                   dos.writeByte(13); // line feed for each line
              dos.writeByte(10); // line feed for each line
                   // close here
                   dos.close();
              } catch (IOException e) {
                   System.err.println("File error: " + e.getMessage());
         public boolean processFile(String fn)
              boolean OK=false;
              int exitcounter;
              try {
                   im = getToolkit().getImage(fn);
              catch (Exception e)
                   System.out.println("1HOLY MOLY THIS NEVER HAPPENS!!!! "+e);
              MediaTracker tracker= new MediaTracker(this);
              tracker.addImage(im,0);
              try {
                   tracker.waitForID(0);
              catch (InterruptedException e)
                   System.out.println("2HOLY MOLY THIS NEVER HAPPENS "+e);
              if (tracker.isErrorID(0)) {
                   System.out.println("IMAGE FILE COULD NOT BE LOADED");
                   System.out.println(fn);
              } else {
                   exitcounter=0;
                   while ( ((W==-1)||(H==-1)) && (exitcounter<=16000000) )
                        W=im.getWidth(null);
                        H=im.getHeight(null);
                        exitcounter++;
                   if (exitcounter>15999999)
                        System.out.println("Timeout attempting to load image, is it to big?");
                   else
                        OK=true;
              return(OK);
         public static void usage() {
              //System.out.println("Usage:");
              //System.out.println("java img2html infile outfile ");
              //System.out.println(" infile : image file .gif ");
              //System.out.println(" outfile : html file to be created");
              //System.out.println(" /i : Inverse data ");
    }     // end of class

  • How to convert for 1 bit image

    dir sir;
    i want to make a programe by it i want to upload image real image and then it converted it for 1 bit image ;
    can i use java to do that?
    and if soo what method and package and function helps me to do that .
    if you can provide me with simple code i will be thankfull.
    beast regards.

    Try using the IMAQ Cast Image function under Motion & Vision>>Vision Utilities>>Image Management>>IMAQ Cast Image.
    Regards,
    Steve

  • How To Convert Multi Page Tiff Image Through open office in application

    I will Appreciate Any Effort Or Reply Which Can Tell Me , To convert a multi-page tiff image in pdf format in application i.e not on desktop using simple open -office but through coding. I doubt if there Exists Ny Plugin Or Separate Library Which Can Do Tht.  Code Or Library inJava Language will Be Preferable

    Your question does not make any sense. First, PDF does not support multi-page TIFFs. DO you have a PDF that you are trying to convert to WORD or what. It is unclear of what you are starting with and what your end goal is. If you are dealing with coding, you may need to check the SDK forum, but trying to understand what you are trying to do would be a good idea first.

  • How to Convert FLIR Gray Scale Image to a Temperatur​e Map in NI VBAI

    I have been working with a FLIR A315 Infra-Red camera and NI's VBAI software.  I need to determine the presence and continuity of a hot mastic foam that has been injected into the hollow bulb of a rubber weatherstrip seal in 4 adjacent locations that flow together inside the weatherstrip bulb to form a continuous foamed mastic plug.
    So far, I have been able to trigger image acquistions in VBAI from a FLIR IR camera by monitoring an Allen-Bradley PLC's status bit.   The communication with the FLIR A315 camera is via the IMAQdx GigE driver.  However, I haven't figured out how to detemine the temperatures from the gray scale images I receive from the FLIR camera.  I wonder if someone could give me some pointers on how to do this.
    I have attached some images below to illustrate what I am working with and how far I've gotten.
    iPhone_Photo.jpg - shows a photograph of the weatherstrip section that the FLIR IR camera is "looking" at.
    FLIR_IR_Monitor.jpg - a screen capture of a FLIR IR monitor utility that shows temperatures measured at a number of points and areas (showing it can be done)
    NI_VBAI.jpg - part of my VBAI 2010 project which shows the image I've acquired from the FLIR A315 IR Camera
    So, I am part of the way there, but so far have not found a way to map the gray scale image that VBAI is acquiring from the FLIR IR camera into a heat map from which I can determine temperatures - and would appreciate some help on how to do this.
    Kind regards,
    Nick
    Solved!
    Go to Solution.
    Attachments:
    iPhone_Photo.jpg ‏239 KB
    FLIR_IR_Monitor.jpg ‏113 KB
    NI_VBAI.jpg ‏205 KB

    Hello,
    Image provided by FLIR camera are unsigned 16bit.
    Depending on the FLIR temperature scale you selected (10mK or 100mK), you will have to divide by a 10 or 100 factor to get K values. Don't select radiometric output.
    So if your object is cold, the population of the histogram of your image will be on the left part of it and if the object is hot, the population of the histogram will be on the right part.
    If you want your temperature values in Celcius, just add 273,15 to the Kelvin Value.
    Then you can add a color palette in VBAI (FLIR iron is available)
    Hope this helps

  • How do I play back jpg images quickly

    I created a series of jpg images as an animation project. I now have 600 jpg images and want to create an 18 second clip with them. When I imported them into Premiere Pro CS5.5, and then added them to my timeline they each play for 5 seconds. I need for them to play at .03 seconds each to create the 18 second clip. How do I change the length of time each is displayed in Premiere Pro CS5?

    For easy searching, download the product user guide PDF(s)
    The individual CS5 pages also have links to the earlier user guide pages
    CS5 User Guides - online and PDF (right click PDF link to save PDF to your hard drive)
    http://blogs.adobe.com/premiereprotraining/2010/08/help-documents-for-creative-suite-5-pdf -and-html.html
    The July 12 2010 CS5 user guide I downloaded has the information you want on page 272

  • How does a BufferedImage store the image?

    Hello
    I have to read the colors of different pixels in a BufferedImage which is bigger than 1800x1800 pixels. Im using getRGB(x,y) to get the pixels color. Is the image in the BufferedImage stored in its compressed form (png) and does it therefore always have to decompressed when i call getRGB(x,y)?

    Huttu wrote:
    Because there are several images for different purposes I store them in a zip-file. I load them using an ImageIO.read(zipFile.getInputStream(ZipEntry));I am totally out of my league here, but what if you create a BufferedInputStream with the inputStream obtained from the zipFile, and read with that?
    BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(ZipEntry));
    ImageIO.read(bis);Again, this is a SWAG, so I have no idea if it will help or not. Also, I have not compiled or run this.

  • How can I get back my images,contacts from my lost ipod touch gen 5?

    A few days ago, someone stole my ipod. I used Find My iphone but I can't found it. But I had a lot of important photos in that ipod. I really really want to get them back. Please, give my some solutions. Without using Find my iphone.

    If you did not backup the contents to iCloud, there is no way to recover material from a lost/stolen iOS device.  You have to have it in your possession to get material off the iPod.

Maybe you are looking for

  • Material to sale both in domestic and export market

    Dear Experts, If we need to sale a particular finished material in domestic and export scenario then is it necessary to maintain two material master data for one material? If not necessary then how to maintain master data? Regards Jyoti

  • Generate IDOC FM IDOC_INPUT_*

    Hello I would like to ask what are the steps to generate the Idoc function module such as IDOC_INPUT_MBGMCR and IDOC_INPUT_DELVRY.  Thanks

  • Will iPhone ever be able to print to wireless BT printers?

    I am loving my iPhone, and one day hope that this becomes a feature! How cool would it be to print from this thing?

  • Adobe Auto Analyser

    I had a trial Adobe Elements 12 (from adobe not from app store)on my MacBook Pro retina (4 gb ram) but did not like it so uninstalled it,  but Adobe Auto Analyser was still in login items, the performance on Mac mainly Pixelmator slowed to almost unu

  • IPod nano is it actually bad?

    SO I really want an iPod. The nano fits my budget. SOOO! I heard that they are riddeled with issues. Is this true? If so what issues? Is scratching one of them? If so can I buy an iSee case in Canada, and where? Does iSee have an official website? Li