BufferedImage from jpg

Anyone know how to make a BufferedImage object from a file like a gif or jpg? thanks

yeah, but don't use TYPE_3BYTE_BGR, it has a component color model, so is slow :-P
use TYPE_INT_BGR, TYPE_INT_RGB,(direct colormodels)
or TYPE_INT_RGBA if u want an alphachannel.
rob,
Image  image;
image  = getToolkit().getImage("f4.gif");
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(image,0);
try
     tracker.waitForID(0);
catch (InterruptedException e){}
BufferedImage bI = new
BufferedImage(image.getWidth(),Image.getHeight(null,Buf
eredImage.TYPE_3BYTE_BGR);
Graphics      g  = bI.getGraphics();
g.drawImage(image,0,0,null);Noah

Similar Messages

  • BufferedImage from JPG File???

    Hello,
    Does anyone know how to make a BufferedImage object from a file like a
    GIF or JPG? Please give me some code.. Thanks so much.
    Charlie

    You got it wrong:
    Image image = getToolkit().getImage(name.jpg);
    int imageWidth = image.getWidth(null);
    int imageHeight = image.getHeight(null);
    BuffereedImage imageBuffer = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
    Graphics2 graphics = imageBuffer.getGraphics();
    graphics.drawImage(image, 0, 0, null);
    noah

  • Problem printing PDF picture files imported from JPG using HP Colour InkJet cp1700 printer

    When I print PDF picture files imported from JPG using an HP Colour InkJet cp1700 printer, the picture spills over.  A wide range of other PDF files print OK.  Have tried things such as configuring the printer to scale to letter size, etc,, but without success.  Have a Windows 7 64 bit computer and Adobe Acrobat Pro Extended 9.5.5.  Any ideas?

    Hello there! Welcome to the forums @rt70 
    I understand you're having some issues with printing PDF files from a website on Windows 7.
    I would personally suggest trying to print from that website using a different web browser. If you're using Internet Explorer, try FireFox or Chrome, for example.
    You can also try running the Print and Scan Doctor tool, that will search and try and fix printing issues.
    If you have any issues that continue, please let me know what they are and which programs, websites, and web browsers you have tried, along with the results from running the diagnostic tool above.
    Good luck and have a great day
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • DNG Profile Editor: Can't create profile from JPG file

    Guys, could you tell me why DNG Profile Editor fails to create color table using 4 colored circles ? It says "Unable to check white balance using gray patches. Please use the four color circles to identify the four corner patches of the chart and try again" even though I places four circles properly (it works with DNG files shot with my Nikon D700).
    I created this DNG file from JPG file by opening it in Camera Raw plugin and saving as DNG file. Original JPG was shot on camera of Samsun Galaxy S phone. I know I'm crazy but I want to have color profile for it All patches are properly exposed after slight correction of Exposure slider in Camera Raw.
    I'm using latest beta3 build
    Here is link to DNG and JPG file I'm trying to use
    http://www.box.net/shared/4v2rzlzjfp
    Thanks!

    If you convert your JPG to a DNG can you change the profile to the one you computed from the other JPG you converted to a DNG?
    Profiles are not for JPGs.  Profiles are for RAW files that ACR supports.  You can't (easily/ever) get a RAW file from your Galaxy S and Adobe doesn’t' support that RAW format even if you could.
    To see if your profiling is working, you can used the ColorCheck module from a trial version of Imatest that you download from www.imatest.com and look at the color-error.
    You can also try the Read_Color_CC24.jsx script from Rags-Gardner:
    http://www.rags-int-inc.com/PhotoTechStuff/ColorCalibration/

  • How do I keep photoshop from changing extensions from .JPG to .jpg

    How do I keep photoshop from changing extensions from .JPG to .jpg?

    Preferences > File Handling and uncheck "Use Lower Case" (Mac)
    or in the same area in the Windows version, choose "Use Upper Case" from the drop-down menu.
    Gene

  • Creating bufferedimage from scene in different resolution than the Canvas?

    Is it possible to create a bufferedimage from a Canvas, but with a higher resolution without loosing image quality?
    Need to take high-quality screenshots of the 3d-scene.
    Thanks.

    I'm trying to back up and simultaneously organize my photos from my Mac OS 10.8.5 by dragging groups of photos from iPhoto to an external HD.
    One more thought -  if you want to backup your photos, why not simply copy your iPhoto Library to the external drive? That would save your photos as well as the work you invested in editing and tagging them.
    If you do the backup by storing only the photos on your external drive, you need to export all edited photos twice - first the original photo like described in Old Toad's screenshot, and then the edited version as well, or you will lose your editing work, if you need your backup.
    Copying the iPhoto Library would save all in one, without too much trouble.
    Your second goal, reorganizing, could be done directly in iPhoto.

  • Pdf from jpg with OCR asks to "save to online account"

    Anyone know whether using OCR on Acrobat XI saves my data on Adobe server thru online account? When creating a pdf from jpg there is a toggle, "save to online account".  I prefer not to store my data in the cloud or on any server--I save only to my personal computer.  Thanks for clarifying this for me.

    When you choose an online account the documents will be saved there otherwise on the local disc.

  • Creating BufferedImage from Image

    I've figured out one way to create a BufferedImage from an Image, but I'm sure it's not the best way.Image im = Toolkit.getDefaultToolkit().getImage(files.getAbsolutePath());
    JLabel jl = new JLabel(new ImageIcon(im));
    BufferedImage bim = new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_BYTE_INDEXED);
    Graphics g = bim.getGraphics();
    jl.paint(bim.getGraphics());
    This works, but I'm sure there has to be a better/easier way. Any suggestions?
    Thanks,
    m

    close, the best way is this...
    public BufferedImage createBufferedImage(Image img)
    BufferedImage bimg = new BufferedImage(img.getWidth(null),img.getHeight(null),BufferedImage.TYPE_INT_RGB);//or whatever type is appropriate
    bimg.getGraphics().drawImage(img,0,0,null);
    return bimg;
    }

  • Creating PDF from JPG files

    I scan several pages from a book and wish to compile a PDF file from the scanned JPG files. What I want is the PDF file to be as small as possible, using relatively good JPG files (they are on the order of 300k), so that the fonts don't look too blurry when magnifying the image in Acrobat. My PDF file gets to be very big when creating a file composed of around 100 scanned pages. How can I make the file smaller?
    I can't use optical character recognition to convert the text of the page. Much of the text contains mathematical symbols and figures, but is generally just black-and-white.
    I feel the large file size of the resultant PDF file is due to all the "white space" of the JPG file. Is there some way to have Acrobat "ignore" the white when creating the PDF file, and then just display the information part of the JPG file on a white background?
    Remember, I'm creating a PDF file from scanned textbook pages, not photographs. I would think that there is an optimum way to do this, keeping good resolution of the text (the "black" or non-white information), and minimizing the file size of the resultant PDF file.
    Any thoughts?
    I have Acrobat 8, Photshop Elements 6, and Windows Vista Ultimate.
    Thanks

    For starters, you should be sure and scan them as grayscale. Then the "white space" won't be an issue.
    Basically the answer is going to be in your initial scan. You need to optimize the files as best you can there first then create the PDF.

  • Sync is not working correctly from .jpg to .nef

    I am working on editing a large collection of photos, maybe 150 or 160. These are photographs of flat art taken using a flat-art photography stand (camera points directly at floor, art piece is on larger white background). I have two versions of the exact same image, one .jpeg and one .nef. I am editing them one at a time, fixing the white balance, any accidental tilt, and cropping them. Again, the two images are exactly the same: size, angle, etc. What I have been doing is editing the .jpg and then highlighting the .nef version and syncing the two. This has been working perfectly, but something has changed and I don't know what I did to cause it. When I sync the changes I have made to the .jpg, the crop does not line up correctly on the .nef image. Instead of the image being perfectly centered and cropped, it is off to the side, revealing the white background and cutting off the image. Why is this happening? How can I fix it?

    What dj wrote regarding crops is equally true for all and any edits you do to the NEF, including any you paste from the jpg. Those edits exist only in the catalog  and additionally in an XMP file if you opt for that. Thus the modifications to the NEF will be viewable only in your LR catalog or by somebody else (with the accompanying XMP) in Adobe software.
    Also, you should consider that color-critical edits cannot simply be pasted from a gamma corrected image rendered in a narrow  RGB space to linear and wide gamut image data and be the same.  If it's a jpg from the camera it is in either sRGB or Adobe RGB, narrower gamuts than LR's linear ProPhoto RGB and colors have already been changed in the camera by both the Rendering Intent and the Tonal Response Curve. Moreover, the camera's jpg has been built on a Nikon camera profile while both viewing within LR and exports from it are on the basis of an Adobe profile that may seek to emulate the maker's profile but will never be the same.
    You say you do WB adjustments to the jpg. How are +/- tweaks in a limited range applied on top of the camera's WB supposed to translate to WB for the NEF when even the UI (Temperature and Tint) is different?
    I have had many years experience photographing paintings for show catalogs and your method seems fundamentally flawed to me.

  • How to get byte array from jpg in resource for Image XObject?

    Hi,
    Does anyone know how to get an array of bytes from a jpg from resource without an external library except MFC?
    The array of bytes is needed to create an Image XObject so it can be included in an appearance for an annotation.

    Sounds like a standard Windows programming question, not specific to the SDK.

  • Converting from jpg to pdf

    how do i convert pictures sent to microsoft outlook from phone to pdf files.. they come in jpg?

    Hi,
    Are you currently subscribed to our CreatePDF online service?
    Kind regards, Stacy

  • Photos changed from jpg to png?

    I just bought a new iphone 4 from the Apple store because my old iphone 4 had a broken power button that could not be replaced. This iphone was working fine- it updated to iOS 7 and all of my contacts and apps synched onto it fine. Now I'm having a problem with my pictures. When it uploaded the pictures I had on my previous backup, it uploaded them in png format, not as a jpg. Now every picture I take on the iphone 4 is in png format which will not upload onto my iphoto on my MacBook Pro (which is from 2009). Ang suggestions on what to do?

    Since an iTunes upgrade in May 2011, iTunes converts jpg to png if the artwork is added to multiple tracks using the get info window.  Artwork added to individual tracks in the get info window, or artwork added to multiple tracks in the artwork box on the browser (the lower left corner where it says "Drag Artwork Here" if there is no artwork).
    Now, to add jpg artwork to multiple tracks, the artwork has to be added via the artwork box on the browser.  If there is existing artwork, this must be deleted first or the new artwork will not replace it bet will be added as a second file (this can be seen on individual track in the get info window).
    The problem with conversion to png format is that the size is increased (doubled or more).
    There are two problems with adding to the artwork box for multiple tracks.  First is the issue that previous artwork must be deleted since adding to the artwork box does not replace existing artwork.  Second is an issue which occurs if you are also playing tracks while adding artwork.  This is due to another problem with iTunes; that the artwork box changes automatically from "Selected Item" to "Now Playing".  If it is set to "Now Playing", the artwork is added to that track, and not the selected tracks.  Also, it takes a short time to add the artwork, and if iTunes switches to the next track in the middle, it stops adding artwork to the selected tracks..
    So, to add jpg artwork to iTunes, you need to do the following:
    1. Delete existing artwork from the tracks.
    2. Make sure the artwork box title is "Selected Item" and not "Now Playing"
    3. Drag new artwork to the artwork box
    4. Make sure the artwork box does not switch to "Now Playing" while artwork is being updated.
    I recommend not playing tracks while adding artwork, to avoid problems with either updating the wrong tracks or not completely updating the selected tracks.
    And I wish iTunes was changed back to the way it was.  Using the get info window did not have these issues.

  • To obtain BufferedImage from Scene 3D

    Hi all!!! I want to obtain snapshots from Scene 3D to do a video with JMF (Java Media Framework). How I do it??
    Regards!

    // read the buffer to byteBuffer
                GL11.glReadBuffer(GL11.GL_FRONT);
                ByteBuffer pixels = ByteBuffer.allocateDirect(400*400*4);
                GL11.glReadPixels(0, 0, 400, 400, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, pixels);
                ColorModel glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                new int[] {8,8,8,0},
                                                false,
                                                false,
                                                ComponentColorModel.OPAQUE,
                                                DataBuffer.TYPE_BYTE);
                int[] bitMasks = new int[] {8,8,8,0};
                int[] band = new int[3];
                // again, what is this?
                SinglePixelPackedSampleModel sampleModel = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, 400, 400,bitMasks);
                // make array from byteBuffer to make a DataBufferByte from array...
                byte [] byteA=new byte[400*400*3];
                System.out.println(byteA.length);
                pixels.get(byteA);
                DataBuffer db = new DataBufferByte(byteA, 400*400*3, 0);
                //make my raster
                WritableRaster raster = Raster.createInterleavedRaster(db, 400, 400, 400*3, 3, band, null);
                // make my image
                BufferedImage image = new BufferedImage(glColorModel, raster, false, null);//new java.util.Hashtable());the above produces an image! yey! it is however grayscale, can anybody help?
    Edited by: IJustWantToSayHelloWorld on Aug 5, 2009 4:12 AM

  • Image convert from jpg to BMP (black & white)

    Hi everybody
    here i am converting a jpg file to 2 bit monochrome image.
    Though this program is making the bmp monochrome image of passing jpg image.
    but the program is hanged in between.
    I don't understand the why it is hanging..though it is generating the result.
    please help me to solve the hanging problem.
    =================================================================================
    source output is:
    C:\j2sdk1.4.1_02\bin>java jaiexp.JAISampleProgram6 aish5.jpg
    1
    2
    FarmHouse2.bmp image
    ERROR: it doesn't finish gracefully....!!
    ==================================================================================
    source code
    package jaiexp;
    import java.awt.Frame;
    import java.awt.image.renderable.ParameterBlock;
    import java.io.IOException;
    import javax.media.jai.Interpolation;
    import javax.media.jai.JAI;
    import com.sun.media.jai.codec.BMPEncodeParam;
    import javax.media.jai.RenderedOp;
    import com.sun.media.jai.codec.FileSeekableStream;
    import javax.media.jai.widget.ScrollingImagePanel;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.image.renderable.*;
    import javax.media.jai.*;
    import javax.media.jai.widget.*;
    import com.sun.media.jai.codec.*;
         * This program decodes an image file of any JAI supported
         * formats, such as GIF, JPEG, TIFF, BMP, PNM, PNG, into a
         * convert it to BMP and save it as bmp file
         public class JAISampleProgram6 {
              /** The main method. */
              public static void main(String[] args) {
                   // Define the source and destination file names.
                   String outputFile = "C:\\j2sdk1.4.1_02\\bin\\jaiexp\\FarmHouse2.bmp";
                   Image bwImage = null;
                   /* Validate input. */
                   if (args.length != 1) {
                        System.out.println("Usage: java JAISampleProgram " + "input_image_filename");
                        System.exit(-1);
                   }//if ends
                   * Create an input stream from the specified file name
                   * to be used with the file decoding operator.
                   Image colorImage = null;
                   try {
                        colorImage = Toolkit.getDefaultToolkit().createImage(args[0]);
                   } catch (Exception e) {
                        e.printStackTrace();
                        System.exit(0);
                   }//try catch ends
                   ImageFilter filter = new BlackWhiteFilter();
                   ImageProducer producer = new FilteredImageSource(colorImage.getSource(),filter);
                   bwImage = Toolkit.getDefaultToolkit().createImage(producer);
                   // Create the ParameterBlock.
                   ParameterBlock pb = new ParameterBlock();
                   pb.add(bwImage);
                   // Create the AWTImage operation.
                   //PlanarImage im = (PlanarImage)JAI.create("awtImage", pb);
                   RenderedOp image1 = (RenderedOp)JAI.create("AWTImage", pb);
                   System.out.println("1");
                   try {
                        FileOutputStream stream = new FileOutputStream(outputFile);
                        System.out.println("2");
                        javax.media.jai.operator.EncodeDescriptor.create(image1,stream,"BMP",null,null);
    System.out.println("3");
                        javax.media.jai.operator.FileStoreDescriptor.create(image1,outputFile,"BMP",null,null,null);
                        System.out.println("4");
                        stream.close();
                   }catch(Exception e){
                        System.out.println("Error:"+e);
                   }//try catch ends
                   System.out.println("5");
              }//fun ends
         }//class ends
         class BlackWhiteFilter extends RGBImageFilter{
         public int filterRGB(int x, int y, int rgb){
         int alpha = (rgb >> 24) & 0xff;
         int red = (int)(((rgb >> 16) & 0xff) * 0.3f);
         int green = (int)(((rgb >> 8) & 0xff) * 0.59f);
         int blue = (int)((rgb & 0xff) * 0.11f);
         int bws = ((red+green+blue) > 127) ? 255 : 0;
         return ((alpha & 0xFF) << 24) | ((bws & 0xFF) << 16) | ((bws & 0xFF) << 8) | ((bws & 0xFF) << 0);
         }//class ends
    thanks in advance.
    regards
    - Deepak
    email: [email protected]
         

    Also keep in mind that there are two definitions of bitmap. You want the 2-color version where each bit represents one color or the other. However, thanks to Microsoft, their bitmaps are really just uncompressed strings of RGB values, storing each pixel in multiple bits.

Maybe you are looking for