How to convert a Image to an image file...

Hi,
I load an image file in my application and I am trying to run it through a filter and save it without modification.
So this leaves me with an Image object, which I would generally assume is easy to convert to a saved image file... But its not. It seems I need a RenderedImage to do this so I created this function
public static RenderedImage convertToRenderedImage(Image img,
              int wid, int ht, int type){
BufferedImage bi = new BufferedImage(wid, ht, type);
Graphics2D g2d = bi.createGraphics();
g2d.drawImage(img, 0,0,wid, ht, null);
return bi;
}which actually leaves me with an image without content... it appears to be all background color, and no foreground text.
any ideas on how to make an Image into a saved Image file?

ImageIO.write?

Similar Messages

  • How to Convert iTunes Songs (Apple lossless audio file) to a MP3 for E-mail

    How to Convert iTunes Songs (Apple lossless audio file) to a MP3 for E-mail?
    My computer is Windows 7 and my Itunes software version is 1.0.2
    Many thanks in advance...

    iTunes 1.0.2 is +at least+ eight years old.
    The current version is 9.2, and it's free.
    If that was a typo, and you're using something more current:
    In the iTunes preferences, change the import settings to mp3.
    Then select the songs you wish to convert.
    From the "Advanced" menu, choose "Create mp3 version".
    When done, change the import settings back to Apple Lossless.
    That's it.
    BTW, this is the Logic Pro forum, which has absolutely nothing to do with iTunes.

  • How to convert base64 data to an image

    Hello, my enterprise application is receiving base64 enocoded image data in an xml file. Now I need to convert it to a native image formats like jpeg/jpg/tiff/pdf etc. Does anybody know if there are any Java apis (both free/paid) which let you do this. Actually I would not have any idea of what type of image it was when it was initially encoded to base64 format. I am looking for an API/technique that can convert base64 data to any image depending on what I want at runtime.
    Thanks a lot in advance.
    R

    Hi there,
    I've had to deal with exactly the same problem myself. The images I had to deal with were all TIFF files, and that was okay, I'd say one of your first steps would be to find out what format these images are in.
    I used a SAX Content Handler to pull the base 64 image data out of the XML into a String, and then converted the Base 64 String into a byte array. From there I could either simply write the byte array to a file, or if I wanted use ImageIO to create an Image object, work with the metadata or even save it in a different format, though I never actually did that.
    Anyway, here is some code I whipped up to convert the String to a byte array, then write the byte array to disk. Let us know how you get along!
          * Writes a byte array to a file.
          * @param result          String containing base64 image data     
          * @param fileName     File name to write the converted image to
         public static void writeTiff(byte[] result, String fileName) throws IOException {          
              FileOutputStream out = new FileOutputStream(fileName, true);
              out.write(result);
              out.close();
          * Converts a String of base 64 image data, captured from XML, into a byte array.
          * @param      image     A Base 64 String          
          * @return      byte[]          
         public static byte[] convertTiff(String image) throws IOException {          
              byte[] result = new sun.misc.BASE64Decoder().decodeBuffer(image);
              return result;
         }

  • How to convert raster tiles into buffered images?

    Abstract:
    Using the code below i try to render four tiles of an image and then store them in different files. Problem: Only the tile 0,0 gets rendered correctly.
              SunTileScheduler sts = new SunTileScheduler(4,0,0,0);
              sts.scheduleTiles(img, new Point[]{
                        new Point(0,0)
                        , new Point(0,1)
                        , new Point(1,0)
                        , new Point(1,1)
              }, new TileComputationListener[]{
                        new TileComputationListener() {
                   public void tileComputed(Object obj, TileRequest[] atilerequest, PlanarImage planarimage, int i, int j, Raster raster)
                   Hello
    I am using JAI to create a RenderedOp object named img and then call the TileScheduler to render me four tiles. Appearantly the scheduler tiles in 512x512, so the Point Array should render the pixels from 0,0 to 1024, 1024 spread accross four tiles.
    Unfortunatly only the tile 0,0 (-> pixels 0,0,511,511) gets rendered correctly, the other three are black and take 4725 bytes each in the file system. Tile 0,0 takes ~95k
    The TileComputationListener returns a Raster object that i convert into a BufferedImage:
                        BufferedImage image = new BufferedImage(raster.getWidth(),raster.getHeight(), BufferedImage.TYPE_INT_RGB);
                        image.setData(raster);After that i write the image into the file system
                        String fileName = String.format("d:/temp/tile/tiles_%s_%s.jpg", i,j);                    
                        try
                             FileOutputStream stream = new FileOutputStream(fileName);
                             JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(stream);
                             JPEGEncodeParam encodeParam = encoder.getDefaultJPEGEncodeParam(image);
                             encodeParam.setQuality(1.0, true);
                             encoder.setJPEGEncodeParam(encodeParam);
                             encoder.encode(image);
                             stream.flush();
                             stream.close();Tiles seem to be problematic because this constructor
    public BufferedImage (ColorModel cm,
                              WritableRaster raster,
                              boolean isRasterPremultiplied,
                              Hashtable<?,?> properties) {rejects Rasters whose tile index is != 0,0. So it all boils down to this:
    How do i convert a Raster objects into a BufferedImage?
    Regards
    Mark

                                  WritableRaster wr = (WritableRaster) raster;
                                  WritableRaster newRaster = wr.createWritableTranslatedChild(0,0);
                                  BufferedImage image = new BufferedImage(planarimage.getColorModel(),
                                            newRaster,false,new Hashtable());

  • How to convert a Form to a Text file and XML file?

    Hi:
    I want to convert a Form to a Text file and XML file,but I don't know how convert?
    Please help!
    Oracle Form Builder V10.1.2.0.2
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Thanks in advance!

    ..or follow the steps in Mtalink note; Doc ID: Note:196924.1
    Forms XML Conversion Feature ( Converting Forms To XML)

  • Does anyone know how to convert iTunes TV subscription downloads to files that I can put on a backup drive and watch on my TV vs. MacBook?

    I purchased a TV series from iTunes and downloaded the HD version. I then copied it to a backup drive so I could plug it in to my DVD player to watch. This would not work. Does anyone know how to convert the files so they are watchable on TV rather than on my MacBook?

    Video in the new iOS is under the application Videos. You should be able to find things there.

  • How to convert erl scripts into single exe file ?

    hi
    this is not related to java. Does anybody know how to convert perl scripts into exe file in non-readable format?
    regards
    venki

    I believe that ActiveState used to do a Perl compiler.....not sure if they still do and I don't think it was free anyway. Check around their website...
    http://www.activestate.com/

  • How to convert a website to an illustrator file

    Hey community,
    I'm looking to convert a website to an illustrator file.  For example, I would like to take a website, such as cnn.com, and manipulate the font size, the size of the right rail, etc..  Any ideas on the quickest way to do this without having to remock up all of cnn.com?
    Thanks!

    That's just not how web page rendering works. You can try to capture the web site as a PDF in Acrobat and open that and perhaps there will be some editable text and a few other things, but there's a good likelihood that most content will be rasterized and not easily editable. If things were that easy, we'd all be using Dreamweaver or other web tools to create vector artwork instead of AI...
    Mylenium

  • How to convert dll to a java class file?

    Hi folks:
    I have some DLLs in VB and C++ and I wanna to convert them to a java class file. Does anybody know if exist a sw or easy way to do it?
    thanks
    Autair

    Well, I believe you could write JNI to call the functions in the DLLs, although I wouldn't recommend it. (You'd have a non-portable, fragile result.)

  • How to convert Sony camcorder 1080i AIC .mov files to work with Photos app?

    I have a Sony SDR-HD10 camcorder from 2008. It records in 1080i format, and I exported to .mov using the Apple Intermediate Codec, Linear PCM, Timecode format, 1920x1080; Color Profile HD (1-1-1); 2 channel audio.
    I have 121 files totaling 105GB. These files all play fine in iMovie. BUT - when I open them in Quicktime X for Yosemite, it converts them into a file that is about twice the space on the drive. The resulting file is Apple ProRes 422, Linear PCM, Timecode, 1888x1062. It also resets the created and edited date/time.
    I looked at each video and the resulting quality is about the same.
    How can I convert these files into something that Photos will like, but not double in size?
    Also, I should point out that I'm not certain I should be using Photos for movies. I used to use iPhoto for pictures, and iMovie for movies, but hardly ever cared to edit videos and thought iMovie was too bulky and confusing for general playback. With Photos, it will upload everything to the cloud (and I'm paying for it), so i can use Photos as my canonical source for all movies and pictures. I have iTunes Match, and my email is hosted by Google, so I'm getting closer to having everything in the cloud. so far, i haven't gone all in with Dropbox for documents, probably because I'm too paranoid about corruption on a remote device like that if there is any concurrent access.

    Check out the export settings from iMovie. Your exporting in a very high grade format used for editing, you want a delivery format. Ask on the iMovie forum for more.

  • How to convert IDoc-XML to native Idoc-File with in SAP XI/PI

    Hello,
    I have a problem to Create an native IDoc-Format for an File-Receiver.
    The scenario:
    I get an Idoc (ZMATMAS) from a SAP System to an MATMAS-exchange-scenario. One of the non-SAP-receiver-systems needs an other native IDoc-Format as File. So I have to map the ZMATMAS to the receiver Format and write this as File. The problem is, that this file contains the data as IDoc-XML and not as native IDoc-format.
    Has anybody an idea for this problem?

    U need to use sender idoc adapter and file receiver adapter.
    U can do file content conversion at receiver end.
    Content Conversion is basically to convert a text file that contains complex structures into an XML source format and vice versa. It is present only in the File Adapter because it is one of the message protocol which will convert the structure to a desired format.
    There are many blogs for File Content Conversion. Some of them are listed hereunder:-
    Introduction to simple(File-XI-File)scenario and complete walk through for starters(Part1)
    Introduction to simple (File-XI-File)scenario and complete walk through for starters(Part2)
    How to send a flat file with various field lengths and variable substructures to XI 3.0
    Content Conversion (Pattern/Random content in input file)
    NAB the TAB (File Adapter)
    File Content Conversion for Unequal Number of Columns
    Content Conversion ( The Key Field Problem )
    The specified item was not found.
    You may also check the FCC documentation for Sender and Receiver:-
    http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm

  • How to convert a large PDF into smaller files

    How does one convert a large PDF file into smaller files and not get odd page breaks.  Need to get the page breaks at the headers.  Just looking for instructions for an end user of Acrobat Pro who reports getting random page breaks and couldn't get help from the Adobe help desk.  I was directed here when I tried to contact support ... Figure this forum may have information. ... thanks.

    You can't. If you split the file into pages it will remain in the same layout the original has. PDF files were not meant to be edited in the way you're describing.

  • How to convert a Final Cut Pro Movie File to uncompressed Quick Time

    I have to send the highest quality file of my 20 sec sequence. It was edited from a converted file.
    The settings are:
    Vid Rte: 25fps, Frame Size 1024x576, Compressor DV-PAL, Pixel Aspect Square.
    Audio: 48.0 KHz, 16-bit Integer
    I exported the sequence: the FCP Movie File is 72.3MB. How to make a Quick Time without reducing it further through the Compressor?

    See your other thread Ruth ... what you have created here is some kind of Frankenstein format that exists only in your laboratory.
    By the way, an "FCP Movie" as you call it IS a QuickTime movie.

  • How to Convert an internal table into Text File

    Hello friends,
    Can you help me to find out the way to convert an internal table data into a flat file.
    the problem is that my internal table contains fields with data type INT also.

    please  go through the code and the parameter passed to the  finction module  ... since  you didn't show your coding  i am giving you the sample code  also ..
    REPORT y_ss_test_ekko .
    * To hold selection data
    DATA: i_ekko TYPE STANDARD TABLE OF ekko.
    * To hold converted text data
    DATA: i_text(4096) TYPE c OCCURS 0.
    * Selection Screen
    PARAMETERS: p_ebeln LIKE ekko-ebeln.
    * Select data into an ITAB based on the selection Criteria
    SELECT * FROM  ekko
             INTO  TABLE i_ekko
             WHERE ebeln = p_ebeln.
    * Process further only if found some data
    IF NOT i_ekko[] IS INITIAL.
    * Convert data in internal table to a delimited text data
      CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
           EXPORTING
                i_field_seperator    = '|'
           TABLES
                i_tab_sap_data       = i_ekko
           CHANGING
                i_tab_converted_data = i_text
           EXCEPTIONS
                conversion_failed    = 1
                OTHERS               = 2.
      IF sy-subrc <> 0.
        WRITE: / 'Program failed to Convert data.'.
      ELSE.
    *   Download convert data to Presentation Server
        CALL FUNCTION 'DOWNLOAD'
             TABLES
                  data_tab = i_text
             EXCEPTIONS
                  OTHERS   = 8.
        IF sy-subrc <> 0.
          WRITE: / 'Program failed to download data.'.
        ENDIF.
      ENDIF.
    ENDIF.
    reward  points  if it is  usefull   ....
    Girish

  • HOW TO CONVERT SAP DB TABLE TO XML FILE

    Initially I want to store sap db table as xml file so that an external program can read it. Also i want that when table is updated only updated data is stored in xml file.
    Edited by: Sandip Mane on Apr 2, 2008 9:19 PM
    Edited by: Alvaro Tejada Galindo on Apr 2, 2008 12:47 PM

    should do this way
    CALL TRANSFORMATION (`ID`)
    SOURCE output = your_itab[]
    RESULT XML xml_out.
    also check this link
    Convert data from internal table to XML file.

  • How to convert a row value in CSV file to column value

    Hi
    We have one requirement where we have to show the row value to column level value
    for Example:
    Source file will be in below format
    Component Name :101
    **Batch #     **100% Mod     200% Mod      300% Mod      400% Mod     Tensile     Elongation     Thickness*
    8584-17     498     1211     1986     2601     3133 523     0.088
    Output Format has to be:
    **Batch #     **100% Mod     200% Mod      300% Mod      400% Mod     Tensile     Elongation     Thickness Component name*
    8584-17     498     1211     1986     2601     3133 523     0.088 101
    How can we achieve this using shell/Perl script

    .

Maybe you are looking for

  • Problems Calling Graphics by Forms on the Web

    Hi! I'm not able to call a graphic on the web using Forms6i (Version 6.0.8.8.0 (Production)) and Graphics (Version 6.0.5.33.0). I made a call to a graphic using the RUN_PRODUCT built-in. On a client-server connection the call has no problem. On the W

  • How many internal HDs can I add to my G4 AGP tower?

    Hi all, How many internal HDs can I add into my G4 tower? I want to buy and use a SATA controller PCI card to break the 137 mb barrier and add 3 or more hds for my graphics art files, video and music files. Sort like a server right? Thanks web dude

  • Badi for release for purchase order.

    hi all, in me28->release (approve) purchasing documents->release purchasing document..there u have a button (release+save ) button   i want to enhance at that pointi.e when u select the po no and click the button,automatically trigger an email to the

  • How to rotate Apache2.2/logs/access_log without restarting AMS 5.0.1 on AWS.

    The Adobe Media Server 5.0.1 docs say that Logging.xml controls rotating of the Apache access_log file but its not rotating and I don't see how to configure it in Logging.xml. Logging.xml takes care of the AMS log files like Access.log but it doens't

  • Can you change Apple ID?

    We now have an ipad, iphone and iTouch in our house but are using the same Apple ID.  i am tired of getting the kids songs and apps and they are tired of mine!  How change Apple IDs on these devices and do taht mean everyone needs their own itunes ac