Looking for a way to write a BufferedImage to a file

i am currently working with images and transforming them. the image is stored as a BufferedImage object and i was wondering if anybody knows how to write the image back as a new file after its been modified.
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.ImageIcon;
import javax.swing.JSlider;
import javax.swing.event.ChangeListener;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
public class ExampleFramework extends JPanel {
private BufferedImage originalImage;
private BufferedImage filteredImage;
private JSlider slide = new JSlider(1, 50, 25);
private int height, width;
ExampleFramework(String titlebar) {
createBufferedImages();
setUpJFrame(titlebar);
private void createBufferedImages() {
Image image =
new ImageIcon("test.jpg").getImage();
height = image.getHeight(null);
width = image.getWidth(null);
originalImage =
new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
filteredImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics g = originalImage.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
this class is not complete but it should give you an idea of the problem am having. there are 2 buffered images and all am looking for is a way to write the contents of the bufferedimage to a file

First, I get rid of Image:
private void createBufferedImages() {
    BufferedImage image = ImageIO.read(new File("test.jpg"));
    int targetType = BufferedImage.TYPE_INT_RGB;
    originalImage = convertType(image, targetType);
    filteredImage = new BufferedImage(image.getWidth(), image.getHeight(), targetType);
static BufferedImage convertType(BufferedImage src, int targetType) {
    if (src.getType() == targetType)
        return src;
    BufferedImage tgt = new BufferedImage(src.getWidth(), src.getHeight(), targetType);
    Graphics2D g = tgt.creategraphics();
    g.drawRenderedImage(src, null);
    g.dispose();
    return tgt;
}(I don't know how important type RGB is to you, so I put in a convert routine.
If these images are primarily for viewing, I would make them compatible
with the screen by using method createCompatibleImage.
As for writing an image, it can be one line of code:
imageIO.write(bufferedImage, "jpeg", file);See ImageIO[url].

Similar Messages

  • We are currently looking for a way to link images to a design file within programs like InDesign and Illustrator using an HTML link instead of a local file.  We are hosting our images in SharePoint and need the design file to retain it's links, no matter

    We are currently looking for a way to link images to a design file within programs like InDesign and Illustrator using an HTML link instead of a local file.  We are hosting our images in SharePoint and need the design file to retain it's links, no matter who on our network opens the design file.

    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • Looking for a way to programmatically set the visible portion of the front panel when a subVI opens

    I am looking for a way to programmatically set the visible portion of the front panel when a subVI opens.  Haven't found any posts that relate, but I'm not sure how to ask the right question.  To be clear, I want to write a helper VI to go through a list of subVIs to make sure the background images are all in the same place when their respective subVIs open.  I hate manually playing with scroll bars before I save each of the VIs...  I'm figuring I need to find the top/left location of the background image (know how to do this already) and then set a VI FP property to  these values or some offset, but I can't find the relevant property. FP:run-timeposition:custom looked promissing, but only affects the location of the window, not the area of the front panel the window is displaying.
    Solved!
    Go to Solution.

    Cool.  Getting closer.  The way I implemented your suggestion affects the subVI only if it is open.  I can use this to do what I'm after, perhaps putting the code into each subVI.  Maybe open all subs, run the helper, and save.    Seems like I'm missing the elegant version...
    My proof of concept code:

  • Looking for a way to monitor forums for a text string.

    Hi as the subject says I'm looking for a way to monitor various forums for a list of text strings and give me a link to the post. I'm have tried googling but cant find anything specific enough I've tried looking at methabot but am unsure as to if this is the right sort of program, anyone with any experience or ideas in this area would be much appreciated.
    thanks in advance.

    you could write a daemon method which would, every so often, search the forums for the keyword.
    Better yet, you can use google's "site: bbs.archlinux.org keyword format to do your search.
    But, be sure not to do it too often. If you keep banging a particular forum website too often, your ip might get banned.

  • Looking for a way to monitor continous queries

    Hi, I am looking for a way to monitor my continous query cache such that i do not expose coherence libraries to the calling programs. So i need an abstraction of the listener and the returned value(in this case the MapEvent) so that the calling program does not have any knowledge of coherence behind the hoods. So, i need to do this in java(using the likes of observer/event listener etc) Any help in this regard is appreciated. Thanks.

    you could write a daemon method which would, every so often, search the forums for the keyword.
    Better yet, you can use google's "site: bbs.archlinux.org keyword format to do your search.
    But, be sure not to do it too often. If you keep banging a particular forum website too often, your ip might get banned.

  • Looking for a way to broadcast a line in to the Airpot Express?

    Looking for a way to run line input into my macbook and broadcast it to the Airport Express to Play on my Stereo..

    It is discussed on the xfce forums but unfortunately that solution requires editing by hand. However it does seem relatively easy to automate. Writing a graphical program for those tasks is something you'd only have to do once.

  • Looking for a way to get built in audio to be heard out of AirTunes

    Looking for a way to get built in audio to be heard out of AirTunes, not just iTunes.

    thanks for the post, i downloaded that app but like i read, its really a worthless piece of junk, the 2 second delay yet alone i did not succeed to send my iChat audio to my airTunes speakers.

  • Looking for a way to Export Still Image to iPhoto

    Hi I'm looking for a way to export a still image from iMovie 08 to iPhoto 08? The simple drag, help, web search etc doesn't seem to come up with an answer but it's been a long day.
    Thanks

    Find the still within an event clip, right mouse, select add still frame to project. Repeat for all the stills you want.
    In Finder under pictures, you should find files for all the stills you created. Import them into Iphoto and there you have it.
    There is probably an easier way but this is not too bad.

  • Hola a todos , busco una manera de crear un pdf desde la impresora de ios, como lo puedo resolver, gracias. Hi all, I look for a way to create a PDF from the printer ios, as I can solve, thanks

    Hi all, I look for a way to create a PDF from the printer ios, as I can solve, thanks

    Try this process on your Mac. These files will be regenerated by Mac OS X with default settings.
    1. Quit the Mac App Store
    2. Trash the following folders and files; (~ is your Home folder)
    ~/Library/Caches/com.apple.appstore
    ~/Library/Caches/com.apple.storeagent
    ~/Library/Cookies/com.apple.appstore.plist
    ~/Library/Preferences/com.apple.appstore.plist
    ~/Library/Preferences/com.apple.storeagent.plist
    ~/Library/Preferences/com.apple.streagent.plist.lockfile
    Mac HD/Library/Preferences/SystemConfiguration/networkinterfaces.plist
    3. Restart your Mac
    4. Open the Mac App Store
    5. Log into your MAS account

  • Looking for a way to switch views using Javascript

    Hi ! I'm currently studying Acrobat 3D. <br /><br />I've got a PDF document with a 3D Annotation, which was imported from a U3D file. I defined 3 views : "initial", "front" and "top".<br /><br />My problem is that I'm looking for a way to switch views using Javascript. <br /><br />In fact, when I list cameras using the following code, I only get one camera called "DefaultView". So my question is : where has my "initial", "front" and "top" views been ? Is there a way I can switch between them using Javascript ?<br /><br />for(i=1;i<scene.cameras.count;++i)<br />     {<br />          Cam = scene.cameras.getByIndex(i);<br />          <br />          console.println("camera " + i + " : " + Cam.name);<br />     }<br /><br />Thank you very much in advance.<br /><br />françois

    Are the dates on these entries correct??!! Doesn't seem like it. Anyway, just in case, here's some code to help:
    //=========================================================
    backgrounder = new RenderEventHandler();
    backgrounder.onEvent = function(event)
    runtime.removeEventHandler(this);
    canvas = event.canvas;
    background = canvas.background;
    keyer = new KeyEventHandler();
    keyer.onEvent = function(event)
    switch (event.characterCode)
    case 49:
    cam = scene.cameras.getByIndex( 0 );
    canvas.setCamera( cam );
    break;
    case 50:
    cam = scene.cameras.getByIndex( 2 );
    canvas.setCamera( cam );
    break;
    case 51:
    cam = scene.cameras.getByIndex( 3 );
    canvas.setCamera( cam );
    break;
    runtime.addEventHandler( keyer );
    runtime.addEventHandler(backgrounder);
    //inform user
    console.println("Use the 1,2,3 Keys to toggle between cameras");
    //===============================================

  • I am looking for a way or a PDF annotator app to use in a tablet that don't allow deletion as I edit.

    Hi All, I am looking for a way or a PDF annotator app to use in a tablet that don't allow deletion as I edit. I need to use in a controlled process that don't allow user to delete or erase edits once a mistake is made or a rewrite is needed. Thank you

    See How to call Adobe Acrobat 9 APIs to OCR the PDFs through .NET reply 4.

  • I am looking for a way to convert Microsoft Office files to my apple and back again

    I am looking for a way to convert Microsoft Office files to my apple and vise vera.
    <Re-Titled By Host>

    you are asking about Microsoft products and using a laptop, not a workstation Mac Pro.
    The Numbers and Pages Apple Communities. or MS Community if you want those.
    Importing and Exporting, but Numbers and Pages will not do a SAVE into other formats by default, and therefore have to keep using Export which is messy.
    Changing your own thread midstream may not be ['thread hijack'] but it is like having the rug pulled out by changing the subject on us.

  • Looking for a way to export full Popularity Trends data

    Greetings!
    I'm looking for a way to access all "popularity trends" data for a SharePoint 2013 publishing site in one place. I'm probably missing something pretty basic here, (I hope), but it seems if I pull up popularity trends for the site, all I get is
    the hits & unique users for the site as a whole. If I go into my pages library and choose "Most Popular Items," I'm given a search results page that I can't run reports from. And if I select the "popularity trends" link under one of
    those search results, I get a usage report for a single, specific page.
    I've thought about doing a multi-select of pages from my site's Pages library, but I have more than 100 pages in the site, so I still can't get at everything all at once. Plus, the resulting usage.xlsx file just includes a lot of  reports on individual
    pages.
    There's got to be something more all-encompassing than this...right?
    Help!

    Hi,
    According to your post, my understanding is that you wanted to see the all popularity trends data for a site.
    Where did you export the usage report?
    Did you export the report from  Popularity and Search Reports?
    To view the Popularity Trends report for a site collection
    Verify that the user account that is performing this procedure is a member of the Owners group.
    In the site collection, on the Settings menu, click Site ettings.
    On the Site Settings page, in the Site Collection Administration section, click Popularity and Search      Reports.
    On the View Usage Reports page, in the Usage Reports section,  click Usage.
    In the message box, click Open to open the report in Excel, or  click Save or Save as to save the  report.
    Click the tabs to view the usage report for the different usage event types.
    http://technet.microsoft.com/en-us/library/jj715890(v=office.15).aspx
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Looking for a way to create/edit a newsletter online, then be able to generate a customized PDF file

    I am looking for a way to be able to customize a newsletter online, then be able to export/generate a PDF file from that newsletter.
    Basically this is for a friend that is a real estate agent, and currently she is creating the newsletters in MS Publisher. I'm hoping to find a way to be able to allow her to login to a secure area of her webpage(that part isn't a problem) but then be able to create/customize a monthly newsletter that needs to be customizable.
    For example, the August Newsletter will be 2-sided, and most of the newsletter will be the same, but she needs to be able to have a newsletter for different apartment buildings so the customers can just go to their building link/area on the webpage and be able to download that month's custom PDF file that has a portion of the main newsletter that is a table/list of properties for that specific location.  The data will be stored in a database.
    After writing the above, I can probably create a front-end to the database so she can enter everything that way, but I still need a way for her to generate the customized PDFs after she is done with that month's data.
    I was hoping Adobe had something that could be used, or am I stuck using php or Javascript and just doing this with custom scripting?
    Anyone have any ideas?
    Thanks!
    John

    I was hoping Adobe had something that could be used, or am I stuck using php or Javascript and just doing this with custom scripting?
    I think you will have to do the latter.  While you are thinking about writing the PDF file, don't overlook fpdf (google it)....

  • Looking for a way to find out the x,y coordinates of a string inside a PDF

    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.

    vedmack wrote:
    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.AFAIK, a string of text does not have an (x,y) location inside a PDF file. The location is exists on your screen, and will differ whenever you adjust the resolution of it. Text can have a location when it's stored as an image though, but than it's really the location of a certain number of pixels (not necessarily a string!).

Maybe you are looking for

  • Date and time of user

    Does anybody know how to get date and time of the user who is logged in portal? Is this noted in a system table or is there any implemented function which returnes required? I have another problem: when I open a form on a page, I would like that this

  • ?  Lion 10.7

    This is the first time on any Apple Support  Communities I have  Lion 10.7 and Safari 6.05 .   I cannot move the page of Safari at all.  Cannot move it to see the desktop(minor) but cannot move it to see the red,yellow ,green buttons  at the top left

  • Raise exception when get ScreenTop of GuiMenu

    Hi expert, When i get ScreenTop property of a GuiMenu object, It raise an exception. Please help me know how can I get GuiMenu ScreenTop and what control i can get this property. Thanks

  • Advice on internal drives needed.

    It's been two months since I've been here. Things have changed!  I'm not sure what forum to post this in. Besides my primary drive with just the OS and programs, I have in the case, a 750 GB drive that I'm outgrowing  and a 2 TB drive that is over ha

  • Inserting fixed column width data - slow performance

    Hi all, I'm reading in a fixed width data file for insertion into an Oracle 7.3.3 database. I insert just fine but my performance is very poor (25,000 records in ~ 7 minutes). I'd like to use stringTokenizer but since it's fixed width and not delimit