Write Image into BufferedImage?

Hi to everyone
Do anyone advise me on how to write to Image and cast it to the BufferedImage?
I'm facing the nullPointerException when i use the MemoryImageSource.
Any help will be appreciated. Thank You
public void getImage()
          try{
               int w = ((Integer)oin.readObject()).intValue();
               System.out.println("Width: " + w);
               int h = ((Integer)oin.readObject()).intValue();
               System.out.println("Width: " + h);
               int [] buffer = (int[])oin.readObject();
               System.out.println("Width: " + buffer);
               MemoryImageSource ms = new MemoryImageSource(w, h, buffer, 0, 0);
               ms.createImage();
          }catch(Exception e)     {
               System.err.println("Receiving failed: "+ e);
     }

hey knucklehead, the answer is back at your other post.

Similar Messages

  • How to transfer image into BufferedImage?

    Hi everyone,
    I tried looking for such a solution, however, I can't get any API to do this.
    Anyone knows how to achieve it? thanks
    David

    You wanted to copy an Image's contents to a BufferedImage, right?
    So you have something like this:
    Image myImage = ...
    BufferedImage buffImg = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB); //...or whatever
    buffImg.getGraphics().drawImage( myImage, 0, 0, Color.BLACK, null);
    ...

  • Load a redrawn image into a JLabel and save it into a BufferedImage?

    Hello, I'm doing a small application to rotate an image, it works, but I'd like to show it into a JLabel that I added, and also store the converted image into a BufferedImage to save it into a database, this is what I have so far:
    public void getImage() {
    try{
    db_connection connect = new db_connection();
    Connection conn = connect.getConnection();
    Statement stmt = conn.createStatement();
    sql = "SELECT image " +
    "FROM image_upload " +
    "WHERE image_id = 1";
    rset = stmt.executeQuery(sql);
    if(rset.next()){
    img1 = rset.getBinaryStream(1);
    buffImage = ImageIO.read(img1);
    rset.close();
    } catch(Exception e){
    System.out.println(e);
    public void paint(Graphics g){
    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    ImageIcon imgIcon = new ImageIcon(buffImage);
    AffineTransform tx = AffineTransform.getRotateInstance(rotacion, imgIcon.getIconWidth()/2, imgIcon.getIconHeight()/2);
    g2.drawImage(imgIcon.getImage(), tx, this);
    jLabel1.setIcon(imgIcon);
    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    setRotacion(getRotacion() + 1.5707963249999999);
    repaint();
    I get the image from a db, then using the paint() method I rotate the image, it works, but the new image is outside of the JLabel and I don't know how to assign the new one into the JLabel (like overwritting the original) and also how to store the new image into a BufferedImage to upload it into the database converted, thanks in advanced, any help would be appreciated, thanks!!
    Edited by: saman0suke on 25-dic-2011 14:07
    Edited by: saman0suke on 25-dic-2011 15:08

    I was able already to fill the JLabel with the modified content, just by creating a new BufferedImage, then create this one into a Graphics2D object and the drawing the image into it, last part, inserting the modified image into the database, so far, so good, thanks!
    EDIT: Ok, basic functionality is ok, I can rotate the image using AffineTransform class, and I can save it to the database and being displayed into a JLabel, now, there's a problem, the image for this example is 200 width and 184 height, but when I rotate it the width can be 184 and the height 200 depending on the position, but the BufferedImage that I create always read from original saved image:
    bimage = new BufferedImage(buffImage.getWidth(), buffImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Is there a way that I can tell BufferedImage new width and height after rotate it? :( as far as I understand this cannot be done because before the image bein rotated the bufferedImage is already created and, even being able to do it how can I get width and height from rotated image? thanks!
    Edited by: saman0suke on 25-dic-2011 19:40

  • Problem in saving the image into SQL database..

    Hello,
    In my application I have to save image file (say jpg) into the database and retrieve back and display it on the applet. I am through with grabbing the pixels of the image & sending the pixel array to the servlet but I am struck in how to store the image into the database and retrieve the same.
    Can anybody please help me in this regard... its really urgent...
    Thanks in advance
    Swarna

    Hello.
    I've been researching this problem (saving images in a MySQL database) in order to accomplish a task I was assigned to. Finally I was able to do it. I'd be glad if it will be of any use.
    First of all: the original question was related to an applet. So, the post from rkippen should be read. It says almost everything, leaving the code job for us. Since I managed to write some code, I'll put it here, but I'm not dealing with the byte transferring issue.
    To obtain a byte array from a file I'd open the file with FileInputStream and use a loop to read bytes from it and save them into a ByteArrayOutputStream object. The ByteArrayOutputStream class has a method named �toByteArray()� which returns an array of bytes (byte [] b = baos.toByteArray()) that can be transferred in a socket connection, as said by rkippen.
    My problem was to save an image captured by a web camera. I had an Image object, which I converted into a byte array and saved into the database. Eventually I had to read the image and show it to the user.
    The table in the MySQL database could be:
    CREATE TABLE  test (
      id int(11) NOT NULL auto_increment,
      img blob NOT NULL,
      PRIMARY KEY  (id)
    )I had problems trying to use the �setBlob� and �getBlob� methods in the Statement object, so I used the �setBytes� and �getBytes� methods . In the end, I liked these methods most because they where more suitable to my application.
    The database operations are:
        public int insertImage(Image image) throws SQLException {
            int id = -1;
            String sql = "insert into test (img) values (?)\n";
            PreparedStatement ps = this.getStatement(sql);  // this method is trivial
            byte [] bytes = this.getBytes(imagem); // * see below
            ps.setBytes(1, bytes);
            ps.executeUpdate();
            id = ps.getGeneratedKeys().getInt(0); //Actually I couldn't make this line work yet.
            return id;
        public Image selectImage(int id) throws SQLException {
            Image img = null;
            String sql = "select img from test where id = ?\n";
            PreparedStatement ps = getStatement(sql);
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                byte [] bytes = rs.getBytes(1);
                img = this.getImage(bytes); // * see below
            return img;
        }* If the bytes are read directly from a file, I think it is not necessary to convert it into an Image. Just send the bytes to the database method would work. On the other hand, if the image read form the DB will be written directly into files, the bytes obtained from rs.getBytes(1) would be enough.
    The image operations are:
        public byte [] getBytes(Image image) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ImageIO.write(this.getBufferedImage(image), "JPEG", baos);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return baos.toByteArray();
        public Image getImage(byte [] bytes)  {
            Image image = null;
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            try {
                image = ImageIO.read(bais);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return image;
        public BufferedImage getBufferedImage(Image image) {
            int width = image.getWidth(null);
            int height = image.getHeight(null);
            BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2d = bi.createGraphics();
            g2d.drawImage(image, 0, 0, null);
            return bi;
        }That's it. I hope it is useful.

  • How can I save a region of an image into another image?

    How can I save a region of an image into another image? Should I use JAI?
    Java2d? Is there an example?
    Thank you.

    Here is what I try, but I find out I just get a black square for my output image, can you please tell me what am I missing?
              ImageIcon file=new ImageIcon("images/clouds.jpg"); // You can't open bmp files
                   // width, height looks correct:
                   System.out.println (" width" + file.getIconWidth());
                   System.out.println (" height" + file.getIconHeight());
                   BufferedImage bi = new BufferedImage(file.getIconWidth(), file.getIconHeight(),
                   BufferedImage.TYPE_INT_RGB);
                   int x = 0;
                   int y = 0;
                   BufferedImage subimage = bi.getSubimage(x, y, 40, 40);
                   File outputFile = new File("newimage.png");
                   ImageIO.write(subimage, "png", outputFile);

  • How to convert 24bits png image into 8 bits image

    Hi,
    I have gone through some of threads in this forum on changing color bits. But, I still can find right way to change my image (24bits) into different color bits(8 bits). The reason i want to change the color bits because I am getting a GIF image from map server, convert it into PNG format then rescale then into size of mobile phone screen.The PNG image is really has large data length , so the it took a while to load the whole image on screen.
    Note : The following code is taken from few threads in this forum and i have modified it to suit my application.
    I have no idea about Java2d...any help really appreciated...Thanks in advance!!!
    My code is as follow:-
    public File Scale(int width, int height, BufferedImage ImgSrc)
         try
                   //BufferedImage bi = ImageIO.read(ImgSrc);
                   //int w = bi.getWidth(), h = bi.getHeight();
         //Image oldRescale = bi.getScaledInstance(i, j, Image.SCALE_SMOOTH);
         BufferedImage Rescale = rescale(ImgSrc, width, height);
                   //ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
                   //ColorConvertOp op = new ColorConvertOp(cs, null);
                   //Rescale = op.filter(Rescale, null);
         File outfile = new File("map.png");
                   ImageIO.write(Rescale, "png", outfile);
                   BufferedImage fromFile = ImageIO.read(outfile);
                   ColorModel cm = fromFile.getColorModel();
                   System.out.println(cm.getClass() + ", bits/pixel=" + cm.getPixelSize());
              catch(Exception e)
                   e.printStackTrace();
              return new File("map.png");
         public static GraphicsConfiguration getDefaultConfiguration()
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    return gd.getDefaultConfiguration();
         public static BufferedImage copyRescaled(BufferedImage tgt, BufferedImage src)
              Graphics2D g2 = tgt.createGraphics();
    int w=tgt.getWidth(), h=tgt.getHeight();
    hintForBestQuality(g2);
         g2.drawImage(src, 0, 0, w, h, null);
         g2.dispose();
    return tgt;
    public static Graphics2D hintForBestQuality(Graphics2D g2)
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
              RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,
              RenderingHints.VALUE_RENDER_QUALITY);
    return g2;
         public static BufferedImage rescale(BufferedImage src, int w, int h)
    int transparency = src.getColorModel().getTransparency();
    GraphicsConfiguration gc = getDefaultConfiguration();
    BufferedImage tgt = gc.createCompatibleImage(w, h, transparency);
    return copyRescaled(tgt, src);

    First, we need to be clear about what you're trying to do -- is it rescale an
    image or insure that the image is saved with a 8bit pixel depth? Or both? You are also
    using GraphicsConfiguration's createCompatibleImage, which is excellent if you are going
    to display the image immediately because it might be hardware accelerated
    or compatible with hardware format, but you mentioned mobile phone screens, so
    there is no advantage to using GraphicsConfiguration in that case, and if fact, it's
    probably changing your ColorModel when you're not looking.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Example {
        public static void main(String[] args) throws IOException {
            URL url = new URL("http://java.sun.com/developer/technicalArticles/GUI/JavaServerFaces/fig2.gif");
            BufferedImage image = ImageIO.read(url);
            System.out.println("image's colormodel = " + image.getColorModel().getClass());
            BufferedImage rescaled = scaleAndConvertColorModel(image, 0.75, null); //GIF => IndexColorModel
            System.out.println("rescaled's colormodel = " + image.getColorModel().getClass());
            File png = new File("junk.png");
            ImageIO.write(rescaled, "png", png);
            BufferedImage fromFile = ImageIO.read(png);
            System.out.println("fromFile's colormodel = " + image.getColorModel().getClass());
            JPanel cp = new JPanel(new GridLayout(0,1));
            addTo(cp, image, "original image");
            addTo(cp, rescaled, "rescaled image");
            addTo(cp, fromFile, "png file image");
            JFrame f = new JFrame("Example");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            Will rescale and convert colormodel if necessary.
            ColorModel == null => don't convert. May return src if suitable.
        public static BufferedImage scaleAndConvertColorModel(BufferedImage src, double scale, ColorModel cm) {
            int w0 = src.getWidth();
            int h0 = src.getHeight();
            int w = (int) (w0 * scale);
            int h = (int) (h0 * scale);
            ColorModel cm0 = src.getColorModel();
            if (cm == null)
                cm = cm0;
            if (w==w0 && h==h0 && cm.equals(cm0))
                return src;
            BufferedImage tgt = createImage(w, h, cm);
            Graphics2D g = tgt.createGraphics();
            if (scale < 1) {
                Image temp = src.getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING);
                g.drawImage(temp, null, null);
            } else {
                hintForBestQuality(g);
                g.drawRenderedImage(src, AffineTransform.getScaleInstance(scale, scale));
            g.dispose();
            return tgt;
        public static BufferedImage createImage(int w, int h, ColorModel cm) {
            if (w <= 0 || h <= 0)
                throw new IllegalArgumentException("...");
            boolean alphaPremultiplied = cm.isAlphaPremultiplied();
            WritableRaster raster = cm.createCompatibleWritableRaster(w, h);
            return new BufferedImage(cm, raster, alphaPremultiplied, null);
        public static Graphics2D hintForBestQuality(Graphics2D g) {
            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            return g;
        static void addTo(Container c, BufferedImage image, String title) {
            JLabel label = new JLabel(new ImageIcon(image));
            label.setBorder(BorderFactory.createTitledBorder(title));
            c.add(label);
    }

  • How to save GIF frames into BufferedImage with TYPE_BYTE_INDEXED?

    Hi All,
    I have a code that saves every animated GIF frame into BufferedImage of TYPE_INT_ARGB. So an animated GIF will correspond to a list of images with 32-bit pixel size.
    I mainly refer to the code in
    http://forum.java.sun.com/thread.jspa?forumID=20&threadID=629277
    But what I need to do now is to store each frame into TYPE_BYTE_INDEXED image instead. What I'm doing is I get the IndexColorModel from the first frame, and that color model will be shared for all frames.
    As for the frames, I've been trying several ways:
    *1.* read it per usual into 32-bit pixel size image
    sourceImage        = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    RenderedImage renderedImg = reader.readAsRenderedImage(index, null);*reader is the ImageReader for the GIF file.
    then trying to convert the image into 8-bit pixel size by creating new destination image
    BufferedImage destImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, ICM);and then draw the original (32-bit pixel size) onto the newly created image.
    Graphics2D g = destImage.createGraphics();
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
    g.drawImage(sourceImage, imageLeft, imageTop, null);*2.* read it as:
    BufferedImage sourceImage = reader.read(index);then create new 8-bit image and draw the source onto it as No. 1.
    The problem is, for No. 1 , the destination image always lose its transparency. And No. 2 only works well with some GIFs. But mostly the destination image will lose the transparency as well.
    I hope someone more familiar with java imaging can help point out to me where did I do wrong...
    I'm thinking maybe the way I draw the source onto the destination. Or maybe there's another way of getting GIF frames into TYPE_BYTE_INDEXED images..
    Thank you in advanced :)
    Edited by: irma_k on Dec 12, 2007 8:42 PM

    I found that java has weird issues with GIF's (ImageIO wont even write transparency to GIFs when writing to a file).
    But PNGs seemed to work a lot better. Not sure if it will fix your problem, as I don't know all that much about java imaging, but using PNGs seemed to work a lot better for me when I needed to draw transparency.

  • Spliting Image into some parts

    Hi.
    Now, I wont to write applet in java. It'll be the game where the image will be split into some parts ( parts about size for egzample. 30x30 pixels, whole image size 300x300 pixels). The parts of image(30x30) will be mix up.
    I take the cutting of image with using the class PixelGrabber and then writting reading pixels in table and function createImage() create image from this table. Below I put my function unfortunately it doesn't work write. I consider, that cause may be the fact to taken only one pixels. When I try to draw this cutting of image in applet window it apear nothing.
    private Image getImages(){
    Image pierwszy = null,obrazek = null;
    pierwszy = getImage(getCodeBase(),"2.gif");
    int pixels[];
    grab = new PixelGrabber(obrazy[0],0,0,30,30,false);          
    try{
              grab.grabPixels();
         }catch(InterruptedException e){
              showStatus("Przerwanie!");
         Object pix = grab.getPixels();
         if(pix instanceof int[]) pixels = (int[])pix;
         int w = grab.getWidth();
         int h = grab.getHeight();
    obrazek = createImage(new MemoryImageSource(w,h,pixels,0,w));
    return obrazek;          
    I ask for help. I apologise to my English, I hope you anderstand me.
    Thank you.

    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class SubImages
        private JPanel getContent()
            BufferedImage image = createImage();
            BufferedImage split = split(image);
            JPanel panel = new JPanel(new GridLayout(1,0));
            panel.add(new JLabel(new ImageIcon(image)));
            panel.add(new JLabel(new ImageIcon(split)));
            return panel;
        private BufferedImage createImage()
            int w = 200;
            int h = 200;
            BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bi.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(new GradientPaint(0, 0, Color.blue, w, h, Color.orange));
            g2.fillRect(0,0,w,h);
            g2.setPaint(Color.red);
            g2.fillOval(w/4-10, h*3/4-10, 20, 20);
            g2.setPaint(Color.green.darker());
            g2.fillOval(w*3/4-10, h/4-10, 20, 20);
            g2.dispose();
            return bi;
        private BufferedImage split(BufferedImage source)
            int w = source.getWidth();
            int h = source.getHeight();
            BufferedImage split = new BufferedImage(w, h, source.getType());
            int[] rgbArray = new int[w*h];
            try
                source.getRGB(0,   0,   w/2, h/2, rgbArray, 0, w/2);   // nw
                split.setRGB( 0,   0,   w/2, h/2, rgbArray, 0, w/2);   // nw
                source.getRGB(0,   h/2, w/2, h/2, rgbArray, 0, w/2);   // sw
                split.setRGB( w/2, 0,   w/2, h/2, rgbArray, 0, w/2);   // ne
                source.getRGB(w/2, h/2, w/2, h/2, rgbArray, 0, w/2);   // se
                split.setRGB( 0,   h/2, w/2, h/2, rgbArray, 0, w/2);   // sw
                source.getRGB(w/2, 0,   w/2, h/2, rgbArray, 0, w/2);   // ne
                split.setRGB( w/2, h/2, w/2, h/2, rgbArray, 0, w/2);   // se
            catch(RasterFormatException rfe)
                System.err.println(rfe.getMessage());
            return split;
        public static void main(String[] args)
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(new SubImages().getContent());
            f.pack();
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • How to insert image into table and to in Oracle 9i intermedia?

    Mr Lawrence,
    I want to ask something:
    I use Oracle 9i intermedia
    If i use this script:
    CREATE TABLE images (
    file_name VARCHAR2(100) NOT NULL,
    image ORDSYS.OrdImage
    then
    CREATE OR REPLACE DIRECTORY imgdir AS 'd:/data';
    then
    INSERT INTO images (file_name, image)
    VALUES ('tree', ORDSYS.ORDImage.init('file','imgdir','tree.jpg' ));
    I put tree.jpg in directory d:/data in my hard drive.
    Is my tree.jpg file had already get in to my images table?
    I'm little confuse, because when i check my table with this script:
    select file_name, i.image.getWidth() from images i;
    it's show that my i.image.getWidth() for file_name tree is empty.. that mean my tree.jpg doesn't get in to my table.. am i correct?
    N also i want to ask how to display to screen all of my image from images table?
    Is it posible Oracle 9i intermedia to support display image from table?
    How?
    thanks Mr Lawrence

    -- First step would be to create a directory in oracle and map it to the folder where your image resides.
    create directory image_dir as *'c:\image_dir';*
    Then you would have to use a procedure to insert the image in your table. SO first create a table to hold the image. Note that you have to use a BLOB to insert the image.
    CREATE TABLE test_image
    ID NUMBER,
    image_filename VARCHAR2(50),
    image BLOB
    Now let's write the procedure to insert the image in the table above.
    CREATE OR REPLACE PROCEDURE insert_image_file (p_id NUMBER, p_image_name IN VARCHAR2)
    IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := BFILENAME ('image_DIR', p_image_name);
    -- insert a NULL record to lock
    INSERT INTO temp_image
    (ID, image_name, image
    VALUES (p_id, p_image_name, EMPTY_BLOB ()
    RETURNING image
    INTO dst_file;
    -- lock record
    SELECT image
    INTO dst_file
    FROM temp_image
    WHERE ID = p_id AND image_name = p_image_name
    FOR UPDATE;
    -- open the file
    DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
    -- determine length
    lgh_file := DBMS_LOB.getlength (src_file);
    -- read the file
    DBMS_LOB.loadfromfile (dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE temp_image
    SET image = dst_file
    WHERE ID = p_id AND image_name = p_image_name;
    -- close file
    DBMS_LOB.fileclose (src_file);
    END insert_image_file;
    Now execute the procedure to insert the image.
    EXECUTE insert_image_file(1,'test_image.jpg');
    Thanks,
    Aparna

  • What is the fastest way to record and write image data?

    Hello,
    I am new to labview and am using the IMAQ software package to record and write data from a CCD camera to the hard drive. The end goal is a program that records and saves as much data as possible as quickly as possible, for experiments lasting on the scale of days. I have been experimenting with the snap, grab, and sequence methods of recording. To save the image data I was told by NI customer support that TDMS streaming would be the fastest method. I have also been experimenting with the TDMS VIs, however I have found the IMAQ Write File 2 VI to be faster in practice. Am I doing something wrong with the TDMS file structure? Is there a more efficient way to convert IMAQ image data to a dataform that can be written as TDMS? I am posting two of my programs to provide a clearer example of what I am trying to do. The first takes a snap of the image and appends it to a TDMS file. The second is the fastest I have found so far and uses Grab to record the images and the IMAQ Write File VI to save them. 
    Thanks
    Attachments:
    Camera Capture (Snap) and stream TDMS.vi ‏24 KB
    Camera Capture (Grab) and write image.vi ‏24 KB

    Hi
    For me it is no surprise that the second VI is faster then the first one, the reason is you can not compare this two VI with each other.
    In the first VI you work with TDMS files, in the second with png files. That would be much faster, because TDMS files need a lot of diskspace.
    Second point, why do you open, write and close for eacht iteration of the for loop a TDMS file in your first VI? That need really a lot of resources, so it coudn´t be fats as well.
    Save your converted pictures in one array, an after the acquisition you can save it in one TDMS file. When you need for each picture a TDMS file you have to know that this need some time to do this.
    So now for the architecture of your first VI, please look to the LL Sequence.vifrom the examples (C:\Program Files\National Instruments\LabVIEW 8.6\examples\IMAQ\IMAQ Low Level.llb\LL Sequence.vi), there you can see how an acquisition of a number of images have been to do.
    When you like it really fast, you make a producer/consumer architecture (see examples in LabVIEW for that).
    So in the first whileloop you acquire the images, write into a queue and in the second, parallel whileloop you read the queue and save the images. (see attachment)
    Hope that helps
    Kind regards
    Beat
    NI Germany
    Attachments:
    ProducerConsumerData.vi ‏10 KB
    ProducerConsumerData_LV8.5.vi ‏12 KB

  • Loading an image into an Applet from a JAR file

    Hello everyone, hopefully a simple question for someone to help me with!
    Im trying to load some images into an applet, currently it uses the JApplet.getImage(url) method just before registering with a media tracker, which works but for the sake of efficiency I would prefer the images all to be contained in the jar file as oppossed to being loaded individually from the server.
    Say I have a class in a package eg, 'com.mydomain.myapplet.class.bin' and an images contained in the file structure 'com.mydomain.myapplet.images.img.gif' how do I load it (and waiting for it to be loaded before preceeding?
    I've seen lots of info of the web for this but much of it is very old (pre 2000) and im sure things have changed a little since then.
    Thanks for any help!

    I don't touch applets, so I can't help you there, but here's some Friday Fun: tracking image loading.
    import java.awt.*;
    import java.awt.image.*;
    import java.beans.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.imageio.event.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    public class ImageLoader extends SwingWorker<BufferedImage, Void> {
        private URL url;
        private JLabel target;
        private IIOReadProgressAdapter listener = new IIOReadProgressAdapter() {
            @Override public void imageProgress(ImageReader source, float percentageDone) {
                setProgress((int)percentageDone);
            @Override public void imageComplete(ImageReader source) {
                setProgress(100);
        public ImageLoader(URL url, JLabel target) {
            this.url = url;
            this.target = target;
        @Override protected BufferedImage doInBackground() throws IOException {
            ImageInputStream input = ImageIO.createImageInputStream(url.openStream());
            try {
                ImageReader reader = ImageIO.getImageReaders(input).next();
                reader.addIIOReadProgressListener(listener);
                reader.setInput(input);
                return reader.read(0);
            } finally {
                input.close();
        @Override protected void done() {
            try {
                target.setIcon(new ImageIcon(get()));
            } catch(Exception e) {
                JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
        //demo
        public static void main(String[] args) throws IOException {
            final URL url = new URL("http://blogs.sun.com/jag/resource/JagHeadshot.jpg");
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch(url);
        static void launch(URL url) {
            JLabel imageLabel = new JLabel();
            final JProgressBar progress = new JProgressBar();
            progress.setBorderPainted(true);
            progress.setStringPainted(true);
            JScrollPane scroller = new JScrollPane(imageLabel);
            scroller.setPreferredSize(new Dimension(800,600));
            JPanel content = new JPanel(new BorderLayout());
            content.add(scroller, BorderLayout.CENTER);
            content.add(progress, BorderLayout.SOUTH);
            JFrame f = new JFrame("ImageLoader");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(content);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            ImageLoader loader = new ImageLoader(url, imageLabel);
            loader.addPropertyChangeListener( new PropertyChangeListener() {
                 public  void propertyChange(PropertyChangeEvent evt) {
                     if ("progress".equals(evt.getPropertyName())) {
                         progress.setValue((Integer)evt.getNewValue());
                         System.out.println(evt.getNewValue());
                     } else if ("state".equals(evt.getPropertyName())) {
                         if (SwingWorker.StateValue.DONE == evt.getNewValue()) {
                             progress.setIndeterminate(true);
            loader.execute();
    abstract class IIOReadProgressAdapter implements IIOReadProgressListener {
        @Override public void imageComplete(ImageReader source) {}
        @Override public void imageProgress(ImageReader source, float percentageDone) {}
        @Override public void imageStarted(ImageReader source, int imageIndex) {}
        @Override public void readAborted(ImageReader source) {}
        @Override public void sequenceComplete(ImageReader source) {}
        @Override public void sequenceStarted(ImageReader source, int minIndex) {}
        @Override public void thumbnailComplete(ImageReader source) {}
        @Override public void thumbnailProgress(ImageReader source, float percentageDone) {}
        @Override public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) {}
    }

  • Error in importing image into SAP using SE78

    Hi to all,
    I was trying to upload a '.bmp" image into SAP using SE78 but I failed.
    Se78 -> BMAP Bitmap Image -> Graphic -> Import -> Specified the complete path ->given name desc and type .
    Ended up with the following message.
    Graphic TRF_LOGO_REV could not be saved
    (2TRF_LOGO_REV)
    Pls. help as I am not sure whether I missed any step.
    Thankx in advance.

    Hi,
    Go to SE78 Transaction ie Aministration of form graphics,
           there select GRAPHICS General Graphics,under this BMAP Bitmap Images will come.
           select that,then a sub window will appear.
    There give the name of your logo and select the import button which is at the extreme left.
           Then again a sub window appears,there give the path name and name of the logo,and some description then press enter.
    Now the logo is uploaded,for preview you can select last button which is print preview.
    Now goto the form,select the window where you want to print the logo.
           Then in that window place the cursor at tag coloumn and select command line.
           Now go to INSERT and select GRAPHICS.A subwindow appers click on 'stored on Document Server',
           give the name of the logo and press enter.
           Then the image information will be displayed on the form.Save the form and activate it.
    Go to se38 transaction write the print program and execute.
    Regards,
    jaya

  • When importing images into LR5 on my laptop, the photos all have a wide yellow streak through them. This only happens on the laptop; I can import the images onto my desktop LR and there isn't the streak of colour.   Can someone help?

    When importing images into LR5 on my laptop, the photos all have a wide yellow streak through them. This only happens on the laptop; I can import the images onto my desktop LR and there isn't the streak of colour.   Can someone help?
    This is happening even with photos that were taken on another camera, not just mine.  My daughter told me that the laptop recently fell.  The yellow streak is not anywhere else on the laptop, just on the photos in LR.

    I have had this problem on my desktop.  I have been attempting to reproduce it where it can be debugged. Here are some observations/facts in my environment--no conclusions:
    1. I do not import from camera or memory stick directly into LR.  I copy all images (using Explorer) from camera to two different locations (backup location first); and then my working area. In both cases, after files are copied I mark them Read-only.
    2. Poor observation, but in any event: the issue has only occurred when I do a large number of images. Its a poor observation as I have no exact number.  I suspect when I do less than 50 always works well every time.  However, I have also done some very large imports without issue.
    3. Error only occurs with my RAW images--for me that's NEF.  I have multiple cameras--those that only capture jpg images have never had an issue in LR.
    4. Even if the file is marked Read Only issues can still occur.  I then remove the image from the disk using LR -- and then manually (Explorer) copy in my backup image -- re import again and all is well.  I think one time I exited LR and replaced the bad file with a backup and restarted LR and all was well again.
    5. When it occurs I have performed a HASH value on the broken file and on the backed up file to determine if the file contents has changed--and each time the file contents has changed.
    6. I have had this occur immediately after import, but most often it occurs like this... import large number of images; Make changes in Development Module on random image, export jpg of changes--exit LR. Open up LR and file is corrupted.
    7. I have had this issue on multiple USB drives ( okay just 2 different drives have been tested ).
    What next--fire up Process Monitor and monitor the system (specifically LR) to see if it reports any file open for write access when this occurs.  So, far I have not had process monitor actually running when it occurs--one of these days.

  • Show image into an item from URL

    Hi all
    i have to show a gif image into an item, but the source of the file is in a url
    Http://xxx.xxx.xxx.xxx/../../../image.gif
    i tried with web.show_document and with read_image_file, but there's something wrong... (forms 6)
    could you please suggest me the right way ?
    thank you !

    show_document is like opening a new browser window so that doesn't work. Read_image_file is like the name suggests for reading a file, not url so that doesn't' work either.
    You will need to move you files to a drive that the forms server can reach, or use a Java Bean that can load an image from an URL and perhaps even display it. You might find an existing Bean (I don't know of one) or you may have to write one yourself.

  • Can I store RTF file with image into CLOB?

    I have created a WORD template document with company logo heading and format. I have to replace the 'user name', 'date' etc. data every time before I insert into my database. Therefore I store the template doc as RTF format.
    1. Can I insert this doc (RTF with image) into CLOB or I have to store it in BLOB?
    2. I want to store in CLOB because I sometimes have to change to content of the doc with replace statement. Actually, can I replace a string in BLOB too?

    I understand RTF is a binary format and so needs to be stored as a BLOB.
    The DBMS_LOB paackage contains procedures like INSTR() and WRITE() that may do what you what. Take them for a test drive.
    Cheers, APC

Maybe you are looking for

  • Multiple ADE passwords on the same computer

    i have digital editions 3.0 installed on my laptop and download from both Barnes and Noble and overdrive.  I can't seem to "unlock" the Barnes and Noble downloads, the Overdirve works fine.  Can there be more than 1 password on ADE ?

  • OIF 11.1.1.4 - When trying logout of OIF as SP - 500 Internal Server Error

    I have one OIF instance configured as an SP and another OIF instance configured as the IdP. The IdP is integrated with OAM. I can login successfully from the SP and I am redirected to the IdP -> OAM for Login -> IdP -> SP to target resource. I then c

  • PXI 6224 linear position encoder resolution question

    Hello, I am using Quadrature Encoder connected to the counter 0 of NI PXI 6224. As shown in the picture, the decoder is working at X4 mode, I set Distance per Pulse as 2. The measured waveform looks like the resolution is 0.5. My question is:        

  • Image capture won't scan some of "detect separate image"

    When put multiple photos on my scanner using "detect separate images, Image Capture recognizes each separate photo, but when it scans, some of the images come out black, and i have to rescan them. Any ideas?

  • Layering sounds

    Im trying to get all my questions out today. I am trying to figure out a way to layer different sounds into one. Like on EXS 24 is there a way that you can combine several sounds into one, using the given sounds?