BufferedImage to file - Where is the file?

I am trying to make a simple program that loads an image, transforms it to grayscale and then save it to a file. Although it seems to work the file isn't being created (or at least i can't find it in my computer...)
import javax.imageio.*;
import java.awt.*;
import java.awt.Image;
import java.io.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
public class ImageProcessing {
    public static void main(String[] args) {
        try {
            ImageProcessing imageprocessing = new ImageProcessing();
        } catch (Exception e) {}
    public ImageProcessing() throws Exception {
        try {
            BufferedImage inImage = ImageIO.read(new File("myImage.jpeg"));
            int width = inImage.getWidth(null);
            System.out.println(width);
            int height = inImage.getHeight(null);
            System.out.println(height);
            int[] rgbs = new int[width * height];
            inImage.getRGB(0, 0, width, height, rgbs, 0, width);
            int[] grayscale = new int[width * height];
            int[] value = new int[width * height];
            for (int j = 0; j < height; j++) {
                for (int i = 0; i < width; i++) {
                    int alpha = (rgbs[j * width + i] >> 24) & 0xff;
                    int red = (rgbs[j * width + i] >> 16) & 0xff;
                    int green = (rgbs[j * width + i] >> 8) & 0xff;
                    int blue = (rgbs[j * width + i]) & 0xff;
                    value[j * width + i] = (red + green + blue);
                    if (value[j * width + i] > 255) {
                        grayscale[j * width + i] = 85;
                    }else
                        grayscale[j * width + i] = value[j * width + i]/3;
            BufferedImage outImage = null;
            outImage.setRGB(0, 0, width, height, grayscale, 0, width);
            ImageIO.write(outImage, "jpg", new File("c:/myImage2.jpeg"));
        } catch (Exception e) {}
}

Solved.
I thought that setRGB would also create the bufferedImage which i have set before as null. This is the correct code.
BufferedImage outImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB );
outImage.setRGB(0, 0, width, height, color, 0, width);
ImageIO.write(outImage, "jpg", new File("myImage2.jpeg"));

Similar Messages

  • When I import files (copy from jpeg or copy as DNG from raw, where is the full size original stored?

    I have the photos go here file, does LR5 put the untouched original there? Do I need my own file for originals and if so, how does LR5 know where to find the full size original? I have everything working but don't understand where my untouched originals go after import. Say I import off my card to My Pictures/Lightroom Catalog/ Photos go here ..... are my originals there? What if I erase my card now, do I only have partial size negatives basically? I don't understand why LR5 didnt put in an originals do here file that imports the full photo to a stock folder. I am so confused I am about ready to throw out LR5. I even bought your instructional DVD and it doesnt make where the original files location clear, it just repeats that LT5 does NOT import the original, just thumbnail and instructions, where is the program getting the photo when I double click to open it , or am I only seeing a lower resolution version of the photo and the full res is now gone because I formatted the card?

    When you import photos, you can choose "Copy" or "Move" or "Copy as DNG", and then select a destination folder on your hard disk. This happens on the right hand side of the Import dialog box. So your original files go to this destination folder.
    Alternatively, if your photos are already on your hard disk, you can import by choosing "Add" and the original photos remain in the existing location.
    If you're not sure where the photos are, open Lightroom, go to the Library Module, and on the right hand side is the Metadata Panel. Set the dropdown to "Default", and it will show you where your photos are stored. Alternatively, you can right-click on any photo and select "Show In Finder"/"Show in Explorer" and Lightroom will take you to the exact folder where the photo is located.
    So, bottom line, you are in total control of where the originals go, and if your forgot where you put them, or made a mistake, you can always find out where they are.
    What if I erase my card now, do I only have partial size negatives basically?
    If your import was successful, then the photos are now stored on your hard disk. So you have the full size original for Lightroom to work with.
    it just repeats that LT5 does NOT import the original, just thumbnail and instructions
    Lightroom does import the original, which means, in Lightroom jargon, that it records the location and metadata about the photo; in other words, Lightroom knows where the photo is, but Lightroom NEVER contains your photo, your photo is ALWAYS stored on the hard disk.
    Because Lightroom now knows where your photo is located, it is important that you not manage your photos (move, edit, rename, delete) outside of Lightroom. Photo managements tasks now must be done in Lightroom. (There are advanced methods that let you manage your photos outside of Lightroom, but these would be NOT RECOMMENDED for beginners)

  • I am having an issue in PS CS6 (on a Mac) where in the middle of working on a file, it gets corrupted by filling in a grid of squares in my layer masks as well as deleting out those same sections of misc layers throughout the file. I have reset the prefer

    I am having an issue in PS CS6 (on a Mac) where in the middle of working on a file, it gets corrupted by filling in a grid of squares in my layer masks as well as deleting out those same sections of misc layers throughout the file. I have reset the preferences, cleaned up the file. Renamed it to another file and 2 weeks later it is doing the same thing. Luckily I had my main subjects as smart objects and it saved them. This second time I just closed it out and opened it again and it is fine. Anybody else have an issue with this? Also it runs really slow these days on my MacBook Pro Retina 2.6 Core i7 with 16gb Ram.

        Hello APVzW, we absolutely want the best path to resolution. My apologies for multiple attempts of replacing the device. We'd like to verify the order information and see if we can locate the tracking number. Please send a direct message with the order number so we can dive deeper. Here's steps to send a direct message: http://vz.to/1b8XnPy We look forward to hearing from you soon.
    WiltonA_VZW
    VZW Support
    Follow us on twitter @VZWSupport

  • Old mac wont boot xcpt via firewire, want to move iphoto files from old to new, where are the pics stored?

    old mac wont boot xcpt via firewire, want to move iphoto files from old to new, where are the pics stored?

    Photos are stored in your home folder (~pictures).
    Barry

  • Where is the file share located in itunes because i cant find it??

    Where is file share located??

    Still no answer to this important question, nearly a year after it was posted? WHERE IS THE REMOTE BUTTON that we are supposed to pair Remote app on the iPhone with? Here's what the help file says in French :
    Jumeler Remote avec une bibliothèque iTunes
    1. Touchez Remote sur l’écran d’accueil de votre appareil.
    2. Touchez Ajouter une bibliothèque iTunes.Un code à 4 chiffres apparaît.
    3. Ouvrez iTunes sur votre ordinateur, puis cliquez sur le bouton Remote .
    4. Tapez le code à 4 chiffres dans la fenêtre iTunes.iTunes jumelle la bibliothèque de votre ordinateur avec l’app Remote de votre appareil.
    NO REMOTE BUTTON ANYWHERE IN ITUNES THAT I CAN SEE... HELP!

  • Where is the File sharing in Itunes window

    Where is the File sharing in Itunes window?

    Normally set in iTunes->Preferences->Sharing. However, with the paucity of details, such as computer, OS,  iTunes version, and what you're trying to do, just a WAG.

  • Where is the file count in a finder window?

    Where is the file count in a finder window now?  I have nothing in any of the view modes.

    From the Finder Menu bar View > Show status bar

  • IMovie crashed, lost project. How do you SAVE in iMovie? Where's the file?

    Just spent 4-5 hours building a complicated movie from a year's worth of footage. At some point, iMovie crashed. I think I lost all those hours of creative decision making, since I cannot see the file when I reopen iMovie.
    There is no "open" command in the file menu. There is no "save" command in the file menu.
    This would imply that Apple was autosaving for me to save me trouble. Hmm. I can save in almost every program I use, and revert, and save versions.
    How do you save a project in iMovie? I don't see save in the file menu, as has been the steadfast tradition of Apple applications since I purchased my first Mac in 1984. What in the blazes have you done with SAVE? It is so basic.
    Along the same line, where is the project file located on my hard drive? I would like to open it. Since I assume you have been autosaving to somewhere, could you please let me know where my file is saved.
    <Edited by Host>

    This just appeared to happen to me too.  I tried clicking on the file in Movies/iMovie Projects.  That didn't work.
    Then, I made a copy of the  file in a safe place.  I noticed it was 2.2 MB, so something had to be in there.  Next, I started iMovie and clicked the Project Library arrow.  The project was listed there.  I opened it and got back most but not all of the work.  It lost a lot of my audio changes.  Here's the thing.  I worked until about midnight, and then left iMovie up and running til noon.  You would think it would have autosaved the changes by the time I came back.  I suggest making your own copy of the file now and then, just in case.

  • I have uploaded a pdf-file. Where is the command to convert it to docx?

    I have uploaded a pdf-file. to https://files.acrobat.com/?trackingid=KGLHY#folder/0662976a-3059-4bd3-8f49-87041736f7c2.
    It appears in the list of files.
    Where is the command to convert it to docx?

    Hi TRee2,
    When you logon to the Acrobat.com service on the top left corner click on 'Tools' an now on the top right side select 'Export from pdf'.
    Now select the files and click on 'Export'.

  • How do i go about deleting a large number of files at the same time?  where's the easiest place to do it?

    how do i go about deleting a large number of files at the same time?  where's the easiest place to do it?

    A bit vague as to what you intend, but the simple answer is to select all the files you want to delete then either drag to the Trash or CTRL- or RIGHT-click on the selection and choose Move to Trash from the contextual menu.

  • Where is the right path to deploy third party DLL? "Support Files"?

    Hi, After Effetcs developers:-)
    Here is question about install path of DLL for After Effects plug-in.
    I'm developing Effects plug-in run with CUDA, so I have to deploy third party DLL to client PC.
    So where is the right path to put DLL such as cudart32_30_14.dll?
    I think it's under "Support Files", because my plug-in runs with cudart32_30_14.dll
    in "C:\Program Files\Adobe\Adobe After Effects CS4\Support Files"
    Am I right?

    well... that depends.
    when you rely on an external library, the external dll is expected to be somewhere along the path, as it appears in the command prompt.
    places like win32, and sxs folders are in that path.
    you could also put the support dll in the same folder as your plug-in. any process automatically includes it's own directory in the search path.
    if you don't want to put it in any of these pre-set locations, then you have to program the path into the dll loading function.
    if you choose to do that, you can put the support dll anywhere you like.

  • Where is the file that contains info on previous session info on a Mac?

    Where is the file that contains info on previous session info on a Mac? I would like to restore several windows and tabs I had open earlier, but the restore previous session menu item does not appear to be available. I had to install and use an older version of Firefox (3.6) to access a website (Fedtraveler.com) that is not compatible with Firefox 6 and is seems to have cleared out the previous session information. I thought I would use Mac OSX Time machine feature to restore the Firefox file where this the previous session info is kept but I don't know what it is called nor how to find it.

    That is the file sessionstore.js in the Firefox Profile Folder.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/sessionstore.js
    *Help > Troubleshooting Information > Profile Directory: Open Containing Folder

  • Where is the file of the funds of screen in Lion?

    Where is the file of the funds of screen in Lion?

    Two of the Screen Savers folders are initially empty, yes.
    If you want to use photographs for a screensaver, don't put them in those folders, though. Store them somewhere else, then click the "+" button on the screensaver preferences page and choose "Add folder of pictures".
    If you want to use them as backgrounds for desktops, again, don't use the Screen Savers folders, just put them in a new folder somewhere else, then juse use the "+" button on the Desktop preferences pane.
    If you're setting background images for Spaces (virtual desktops), set each one individually. Remember to close System Preferences once you're done with each desktop, then switch to the next one, right-click on the desktop, and click Change Desktop Background again.
    Hope that helps.
    Matt

  • Where is the file that was shared to media browser?

    I'm trying to delete stuff that I don't need. Where are the movie files that are shared to mediabrowser?

    Take a look at this link, https://discussions.apple.com/thread/1687092

  • Where is the file downloaded from WEB browser (e61...

    I'm using e61i (web) to surf web sites. When I downloaded a zip file, ZIP MANAGER launched but I dont know where is the downloaded zip file path.
    Thank you.

    Do you have Yahoo mail on your PC?  If you do, the same email with the attachment will be there.  Otherwise, there are programs you can download such as Dropbox on iPad and dropbox on your PC, which permits file sharing between the two devices.  But, you can't really just download a file to your iPad natively.

  • Where is the file extent map ?

    hello everybody,
    I have a question. In Oracle Cluster, when Database Instace want to do I/O on a database file stored in ASM it first have to interactive with ASM instance. ASM Instace will provide Database Instance with ASM File Extent Map . ASM File Extent Map will show Database Instance where file's extents . After that Database Instance can perform direct I/O to the Database File. So where is the ASM File Extent Map ?What store ASM File Extent Map ? somebpdy can tell me ???

    A complete list in https://twiki.cern.ch/twiki/bin/view/PSSGroup/ASM_Internals
    N.A.     X$KFFXP     extent map table for all ASM files     
    N.A.     X$KFDAT     extent list for all ASM disks     
    N.A.     X$KFBH     describes the ASM cache (buffer cache of ASM in blocks of 4K (_asm_blksize)

Maybe you are looking for

  • Memory upgrade on Intel Mini?

    It is interesting that the documentation now states: "You can upgrade your memory later by taking your system to an Apple Authorized Service Provider or doing it yourself. " I replaced the 256 chip that came w/ my Mini w/ a 1 gb chip and it was very

  • Document generation question

    Hi All, I'm facing a problem with the generate document option as for example I want to create a document with all the employee details I can get the Title, F Name, L Name but i can't get the job, position any suggestions ?? Thanks in advance

  • [SOLVED] Fonts too small on X

    Hi, My fonts are waaay too small for my linking. I've recently migrated to Arch (I don't know what's been keeping me ), and since the doc is *so* great, I've just had two tiny issues. My fonts are really small.  About half the size I'm used to.  I fo

  • Exposing WebService directly from ABAP Class not from BAPI

    Hi guys, is it possible ti expose a Webservice direct from an ABAP OO-Class. I know the possebility to do it for RFC enabled Funktionmodules but I think it is no good coding style to call ABAP-OO-Methods using RFC-Module only for providing them as me

  • TS4036 i need to remove my ios7 for my iphone 5 to be repaired how do i do this?

    my iphone hasbeen sent off to be repaired but they cant do this without me removing my ios7 from icloud how do i do this??