Displaying a picture from an array of pixel values

I have a picture I want to display in an AWT frame. The picture is stored as several arrays of pixel values which represent rectangles.
Each rectangle has a start co-ordinate and a height and width.
There is a ColorModel associated with the pixel values, so that's not a problem.
What's the best way to display these rectangles as pixels, and patch them all together to make the full picture? I'm currently trying to use a MemoryImageSource, but I'm having trouble displaying more than one rectangle at once, and the picture flickers like mad, suggesting MemoryImageSource intended for animation, whereas I just want to display the picture once.
Any suggestions?

OK, that looks good. I'm investigating it.
However, It's not clear how to get the pixel values from an array into it. It requires a WriteableRaster of the pixel data, and to create a WriteableRaster, you need a DataBuffer... which is Abstract!
Do you know how to make a DataBuffer from an array?

Similar Messages

  • IPhoto 9.6 doesn´t display any pictures from library, upgraded

    iPhoto 9.6 doesn´t display any pictures from library. I have upgraded from an old iPhoto. I upgraded the Library also.
    Everything is inside the Library I can see but when I run iPhoto I get only a yellow note on the screen and no pictures?

    Everything is inside the Library I can see
    Do you mean by looking into the library using the Finder?
    but when I run iPhoto I get only a yellow note on the screen and no pictures?
    Then iPhoto has probably opened a new, empty library, because it could not find or access your iPhoto library. What happens, whiny double-click the Library to open it directly?
    Where is your iPhoto library stored? Is it in the Pictures folder or on an external drive?

  • How to create an array in one field and have another field display certain elements from that array?

    I am making a form in Acrobat XI pro.
    In one text field, I created an array of several elements. I want other text fields to display certain elements from that array. For instance, one field should display the 3rd element, another field should display the 13th element, etc.
    The Javascript for making the array is very long, and so I don't want to have to re-calculate the array every single time (in order to reduce rendering time when I open the form on an iPad). This is why I'd like to only have to create the array once, and simply refer to it throughout the form.

    What code are you using to update the array currently? Are you completely rebuiding it when an element changes, or just changing specific elements for certain fields? I'm still not sure what exactly you are trying to do, but something like this in a document level script will create your array:
    var myArray;
    // Call 'updateArray' to initialize array
    updateArray();
    function updateArray() {
         // Code here to create/update array
         myArray = new Array();
         myArray[0] = "Value 1";
         myArray[1] = "Value 2";
         myArray[2] = "Value 3";
    Then, for each field that needs to update this array, you can add a call to 'updateArray()' in the appropriate event. This will rebuild the array completely; if you just want to update specific elements, then you can access them directly.

  • Display an image from an array of bytes

    Hi, I'm trying to display an image from the raw pixel values. lets say i read a bmp file to an array, chuk the header off and want to display the pixel. How can I do this? I don't want any file formats, just want to display the pixels and creat the image. Is this possible?
    Many thanks,
    H

    Thanks for the reply. I had a look at MemoryImageSource and other classes that relates to it. I wrote the example given, but it doesn't identify createImage(). I've implemented ImageProducer, but still complains. Have you any idea why? Thanks for your help.
    H

  • Report to display a picture from a blob column

    hi all
    i have a problem :please help
    environment: oracle AS 10.1.2.0.2 portal version 10.1.4
    i have a slq report:
    select field1,field2...,,
    decode(cd.photo, empty_blob(),
    '<img src="MYCS.show_img?p_field=IMG&p_rowid=NO_CHILD_PIC">',
    decode(cd.SOURCE, 'MAIN',
    '<img src="MYCS.show_img?p_field=CHILD&p_rowid='||mycs_lib.url_encode(cd.rid)||'" width=160 height=120>',
    '<img src="MYCS.show_img?p_field=CHILDARCH&p_rowid='||mycs_lib.url_encode(cd.rid)||'" width=160 height=120>')
    ) "PHOTO"
    from MYCS.mycs_child_details_v cd
    where cd.id like :child_id
    adn ...
    The last field on the (select statement) is a photo(blob type)
    NB:MYCS.mycs_child_details_v is a view
    trying to create the report i get the following Error:
    unable to describe SQL statement. Please correct it (WWV-13010)
    Took exception (WWV-13005)
    ORA-00942: inconsistent datatypes: expected - BLOB wwv-11230
    This report runs without any errors on portal 3.0.9 9i AS
    i dont understand what could be wrong here?
    is BLOB datatype not supported by/on portal?
    is the other way i can display this picture(s)?

    Jean,
    See this thread:
    How can I upload/display image within a record ?
    Sergio

  • To display consecutive words from an array on a keypress. Event listeners not working.

    I need to display a series of words consecutively on a black background. A new word presented each time the Enter key is pressed (It is necessary that its the same key each time i.e the Enter Key). The words are arranged in an array. I have created a function for each Keypress and a listener. Also, as the previous word is replaced by the next, I have a removeChild() to get rid of the the last word.
    I have a removeEventListener set up also, to avoid any problems with the listeners. I have been at this a long time without sucess. It must be a listener problem (i.e I have not got the listeners focussed properly?) or a display problem. It only ever displays one word. Please see below code for the display of two of the words from the array which is called cvcwords. The main problem is that the words do not display one after the other (indeed not at all, except for the first one) when the enter key is pressed. Very much as a powerpoint presentation would, thats the idea anyway. I have just a sample of the code below. any help appreciated.
    var cvcwords : Array = ["bad", "mod", "hud", "mit", "sat", "fog", "puc",];
    this.stage.addEventListener(KeyboardEvent.KEY_DOWN, modKeyDown);
                                  function modKeyDown(e : KeyboardEvent) : void {
                                            if (e.keyCode == Keyboard.ENTER) {
                                                      removeChild(myText);               // to remove previous word from screen
                                                      myText.text = cvcwords[1];        //to display element one of the array
                                                      addChild(myText);
                                            } else if (e.keyCode == Keyboard.SPACE) { //this is for another seperate option
                                                      myText.text = "try again";
                                                      addChild(myText);
                   this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, modKeyDown);
                                  this.stage.addEventListener(KeyboardEvent.KEY_DOWN, hudKeyDown);
                                  function hudKeyDown(e : KeyboardEvent) : void {
                                            if (e.keyCode == Keyboard.ENTER) {
                                                      removeChild(myText);  //to remove previous word from the screen      
                                                      myText.text = cvcwords[2];
                                                      addChild(myText);
                                            } else if (e.keyCode == Keyboard.SPACE) {
                                                      myText.text = "do again";
                                                      addChild(myText);
                   this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, hudKeyDown);

    Based on what I see of your code, the following is all you might need...
    var cvcwords : Array = ["bad", "mod", "hud", "mit", "sat", "fog", "puc",];
    var counter:int = 0;
    stage.addEventListener(KeyboardEvent.KEY_DOWN, modKeyDown);
    function modKeyDown(e : KeyboardEvent) : void {
        if (e.keyCode == Keyboard.ENTER) {
            myText.text = cvcwords[counter];      
            counter++;
        } else if (e.keyCode == Keyboard.SPACE) {
            myText.text = "try again";
            addChild(myText);
            stage.removeEventListener(KeyboardEvent.KEY_DOWN, modKeyDown);
    When you test this in Flash, in the player you need to be sure to select the Diable Keyboard Shortcuts option found under the Control option in the top toolbar
    If you really mean to have them try again, you probably do not want to remove the event listener

  • Creating function to display a picture  from apatche folder?

    how can i create a function so i will pass parameter to the function so that it will call a picture which is stored in the apatche folder to br displayed in the footer of the page .
    thanks ,
    Ahmed

    Jean,
    See this thread:
    How can I upload/display image within a record ?
    Sergio

  • Creating a sound from an array of numeric values and playing it on speakers

    How do I create take a sound I have stored as an array (or could be an arraylist if needed) of numeric values (at the moment as doubles) whiten my program and output it to speakers? I am using blueJ.
    for example (0, 0.1, 0.4, 0.8, 0.9, 1, 0.8, 0.6, 0.3, 0.1, etc...) would be a very high frequency sin wave.
    Edited by: alan2here on Feb 6, 2008 11:28 AM

    I stumbled upon this thread with a question somewhat related:
    I've recorded a wave file from microphone. But what I would like is an array of numbers in the same way alan said. I'm also working on my own project involving signal processing (i'm trying to do speech recognition).
    I can't really find a nice way of getting that array of numbers. I've tried to find out how wave file stores it's data, and directly read from the File object, but i figured there should be an easier way...
    I used this code to read the sound:
    *     SimpleAudioRecorder.java
    *     This file is part of jsresources.org
    * Copyright (c) 1999 - 2003 by Matthias Pfisterer
    * All rights reserved.
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    * - Redistributions of source code must retain the above copyright notice,
    *   this list of conditions and the following disclaimer.
    * - Redistributions in binary form must reproduce the above copyright
    *   notice, this list of conditions and the following disclaimer in the
    *   documentation and/or other materials provided with the distribution.
    |<---            this code is formatted to fit into 80 columns             --->|
    import java.io.IOException;
    import java.io.File;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.TargetDataLine;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.AudioFileFormat;
    public class SimpleAudioRecorder
    extends Thread
         private TargetDataLine          m_line;
         private AudioFileFormat.Type     m_targetType;
         private AudioInputStream     m_audioInputStream;
         private File               m_outputFile;
         public SimpleAudioRecorder(TargetDataLine line,
                             AudioFileFormat.Type targetType,
                             File file)
              m_line = line;
              m_audioInputStream = new AudioInputStream(line);
              m_targetType = targetType;
              m_outputFile = file;
         /** Starts the recording.
             To accomplish this, (i) the line is started and (ii) the
             thread is started.
         public void start()
              /* Starting the TargetDataLine. It tells the line that
                 we now want to read data from it. If this method
                 isn't called, we won't
                 be able to read data from the line at all.
              m_line.start();
              /* Starting the thread. This call results in the
                 method 'run()' (see below) being called. There, the
                 data is actually read from the line.
              super.start();
         /** Stops the recording.
             Note that stopping the thread explicitely is not necessary. Once
             no more data can be read from the TargetDataLine, no more data
             be read from our AudioInputStream. And if there is no more
             data from the AudioInputStream, the method 'AudioSystem.write()'
             (called in 'run()' returns. Returning from 'AudioSystem.write()'
             is followed by returning from 'run()', and thus, the thread
             is terminated automatically.
             It's not a good idea to call this method just 'stop()'
             because stop() is a (deprecated) method of the class 'Thread'.
             And we don't want to override this method.
         public void stopRecording()
              m_line.stop();
              m_line.close();
         /** Main working method.
             You may be surprised that here, just 'AudioSystem.write()' is
             called. But internally, it works like this: AudioSystem.write()
             contains a loop that is trying to read from the passed
             AudioInputStream. Since we have a special AudioInputStream
             that gets its data from a TargetDataLine, reading from the
             AudioInputStream leads to reading from the TargetDataLine. The
             data read this way is then written to the passed File. Before
             writing of audio data starts, a header is written according
             to the desired audio file type. Reading continues untill no
             more data can be read from the AudioInputStream. In our case,
             this happens if no more data can be read from the TargetDataLine.
             This, in turn, happens if the TargetDataLine is stopped or closed
             (which implies stopping). (Also see the comment above.) Then,
             the file is closed and 'AudioSystem.write()' returns.
         public void run()
                   try
                        AudioSystem.write(
                             m_audioInputStream,
                             m_targetType,
                             m_outputFile);
                   catch (IOException e)
                        e.printStackTrace();
         public static void main(String[] args)
              if (args.length != 1 || args[0].equals("-h"))
                   printUsageAndExit();
              /* We have made shure that there is only one command line
                 argument. This is taken as the filename of the soundfile
                 to store to.
              String     strFilename = args[0];
              File     outputFile = new File(strFilename);
              /* For simplicity, the audio data format used for recording
                 is hardcoded here. We use PCM 44.1 kHz, 16 bit signed,
                 stereo.
              AudioFormat     audioFormat = new AudioFormat(
                   AudioFormat.Encoding.PCM_SIGNED,
                   44100.0F, 16, 2, 4, 44100.0F, false);
              /* Now, we are trying to get a TargetDataLine. The
                 TargetDataLine is used later to read audio data from it.
                 If requesting the line was successful, we are opening
                 it (important!).
              DataLine.Info     info = new DataLine.Info(TargetDataLine.class, audioFormat);
              TargetDataLine     targetDataLine = null;
              try
                   targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
                   targetDataLine.open(audioFormat);
              catch (LineUnavailableException e)
                   out("unable to get a recording line");
                   e.printStackTrace();
                   System.exit(1);
              /* Again for simplicity, we've hardcoded the audio file
                 type, too.
              AudioFileFormat.Type     targetType = AudioFileFormat.Type.WAVE;
              /* Now, we are creating an SimpleAudioRecorder object. It
                 contains the logic of starting and stopping the
                 recording, reading audio data from the TargetDataLine
                 and writing the data to a file.
              SimpleAudioRecorder     recorder = new SimpleAudioRecorder(
                   targetDataLine,
                   targetType,
                   outputFile);
              /* We are waiting for the user to press ENTER to
                 start the recording. (You might find it
                 inconvenient if recording starts immediately.)
              out("Press ENTER to start the recording.");
              try
                   System.in.read();
              catch (IOException e)
                   e.printStackTrace();
              /* Here, the recording is actually started.
              recorder.start();
              out("Recording...");
              /* And now, we are waiting again for the user to press ENTER,
                 this time to signal that the recording should be stopped.
              out("Press ENTER to stop the recording.");
              try
                   System.in.read();
              catch (IOException e)
                   e.printStackTrace();
              /* Here, the recording is actually stopped.
              recorder.stopRecording();
              out("Recording stopped.");
         private static void printUsageAndExit()
              out("SimpleAudioRecorder: usage:");
              out("\tjava SimpleAudioRecorder -h");
              out("\tjava SimpleAudioRecorder <audiofile>");
              System.exit(0);
         private static void out(String strMessage)
              System.out.println(strMessage);
    }Daniel

  • How to create PNG file from byte array of RGB value?

    Hi
    Here is my problem.
    I have drawn some sketchs (through code in runtime) on canvas. I have grabbed the RGB information for the drwan image and converted to byte array.
    I have to pass this byte array to server and generate a png file and save.
    Please help.

    {color:#ff0000}Cross posted{color}
    http://forum.java.sun.com/thread.jspa?threadID=5218093
    {color:#000080}Cross posting is rude.
    db{color}

  • Create an image from float array?

    Dear All,
    I have a float array containing pixel values. From that array I want to create an image (let's say in JPEG format).
    How should I do that?
    thanks

    Hi musti168,
    You're going through your entire image pixel-by-pixel and getting each of their values - why don't you just use the IMAQ ImageToArray function?  
    On this forum post I found an example of IMAQ ArrayToImage: http://forums.ni.com/t5/LabVIEW/IMAQ-arraytoimage-​example/td-p/68418
    You can use some of the IMAQ Image Processing palette to change the image to gray scale - possibly a threshold.
    Julian R.
    Applications Engineer
    National Instruments

  • Display one div at a time from an array?

    I am trying to make a multiple choice quiz. I have each question and answer in a div. There are 20 divs. All are set to not display on the stage, and I want to call one randomly to display as the user answers that question.
    For the moment, I am trying to get even one question to display on the stage. Here is my code, which is at the top in the edgeActions.js file inside the first function.
    //Edge code
    (function($, Edge, compId){
    var Composition = Edge.Composition, Symbol = Edge.Symbol; // aliases for commonly used Edge classes
    //my code
    var divs = new Array( 'div.ques1', 'div.ques2', 'div.ques3', 'div.ques4', 'div.ques5', 'div.ques6', 'div.ques7', 'div.ques8', 'div.ques9', 'div.ques10', 'div.ques11', 'div.ques12', 'div.ques13', 'div.ques14', 'div.ques15', 'div.ques16', 'div.ques17', 'div.ques18', 'div.ques19', 'div.ques20' ), idx;
    var idx = Math.floor(Math.random()*divs.length);
    function getQuestion() {
    //the following commands do not work
                        $('idx').show();
                        $('idx').css('display','inline');
                        $('divs[idx]').appendTo(document.body);
                        $('sym.que2').show();
      $('que2').show();
                        $('div.ques1').show();
                        $('ques2').show();
    //these do work
                        alert("blah");
                        console.log('this is working');
                        console.log('id=%d', idx);
              getQuestion();
    Since the console is returning the random number from the array, I have a feeling Edge cannot distinguish the array number from the corresponding div. Converting them to symbols does nothing. I am starting to think it would have been easier to just hand code this rather than using Edge.

    Hi Elaine,
    Thank you for your response!
    Your new randomize line worked beautifully
    I have tried defining my array elements in every connotation I can think of, inlcuding changing them to symbols. I did figure out today that an element has to be displayed before it will even be hit by jQuery, [.show() will not work] and if autoplay is checked while they are off, they will show, and vice versa. Confusing, but it narrowed it down enough for me to see I really just needed to figure out how to call the elements, then figure out all the on/off/autoplay stuff from there.
    Here is my new code in its new location, the compositionReady panel:
    var divs = new Array( 'Symbol_1', 'Symbol_2', 'Symbol_3', 'Symbol_4', 'Symbol_5', 'Symbol_6', 'Symbol_7', 'Symbol_8', 'Symbol_9', 'Symbol_10', 'Symbol_11', 'Symbol_12', 'Symbol_13', 'Symbol_14', 'Symbol_15',
    'Symbol_16', 'Symbol_17', 'Symbol_18', 'Symbol_19', 'Symbol_20' );   // display is on for all symbols
    sym.setVariable("myArr", divs);
    var random = Math.floor(Math.random() * 100) % 20;
    console.log( divs );   //works
    console.log( "myArr" );   //works
    console.log( random );    //works
    function getQuestion() {
             sym.$("myArr").hide();  // doesn't work
             sym.$("myArr").hide();  //doesn't work
                        console.log('this is working');  //works
                        console.log('id=%d', random);   //works
    getQuestion();
    All of the questions are showing at once and I want to be able to hide all of them.
    Array[20] 
    0: "Symbol_1"
    1: "Symbol_2"
    2: "Symbol_3"
    3: "Symbol_4"
    4: "Symbol_5"
    5: "Symbol_6"
    6: "Symbol_7"
    7: "Symbol_8"
    8: "Symbol_9"
    9: "Symbol_10"
    10: "Symbol_11"
    11: "Symbol_12"
    12: "Symbol_13"
    13: "Symbol_14"
    14: "Symbol_15"
    15: "Symbol_16"
    16: "Symbol_17"
    17: "Symbol_18"
    18: "Symbol_19"
    19: "Symbol_20"
    length: 20
    myArr
    17
    this is working
    17

  • Just purchased a new iMac and transferred all info from my old iMac. Now when using iPhoto slideshow is displays the pictures in reverse order.

    Just purchased a new iMac and after transferring all info from my old iMac.  Now when using iPhoto slideshow it  displays the pictures in reverse order.

    There's a bug in iPhoto 9.5.1 and Mavericks that affects slideshows played directly from an album.  The slideshow will not play correctly if the photos have been sorted manually.  Any other type of sort, date, rating, keyword or title, will play correctly.
    If you need that manual sort of pictures for your slideshow create the slideshow in iPhoto's slideshow mode.
    OT

  • I have a MacBook Pro and OS10.6 and am trying to log into a site that requires me to enter a code from a picture ... problem is all I get on the screen is a white '?' in a blue box. What do I need to display the picture?

    I have a MacBook Pro and OS10.6 and am trying to log into a site that requires me to enter a code from a picture ... problem is all I get on the screen is a white '?' in a blue box. What do I need to display the picture?

    Reload the page. If it doesn't load, choose Activity from Safari's Window menu, find that picture in the list, and see what it says to the right; this may reveal what the problem is.
    (91827)

  • HT201401 I had restored my iPhone 4 but after restore my camera can't function well after take picture from the camera it's didn't display in the Photo Gallery even can't take a video record,how to solve this?and i had tried to restore again,still the sam

    I had restored my iPhone 4 but after restore my camera can't function well after take picture from the camera it's didn't display in the Photo Gallery even can't take a video record,how to solve this?and i had tried to restore again,still the same
    kindly reply and fix this for me
    reply to my email,tq

    Most likely you have Office 2004 which are PPC-only applications and will not work in Lion. Upgrade to Office 2011. Other alternatives are:
    Apple's iWork suite (Pages, Numbers, and Keynote.)
    Open Office (Office 2007-like suite compatible with OS X.)
    NeoOffice (similar to Open Office.)
    LibreOffice (a new direction for the Open Office suite.)

  • HT201493 When I add a person in io6 their email is only displayed not their name and picture from my contacts that the email is associated with, why?

    When I add a person in io6 their email is only displayed not their name and picture from my contacts that the email is associated with, why?

    The whole idea to an icloud account is that one user uses it and has all their devices synced together.  Different users need different Apple IDs to create their own icloud accounts.  Note that everyone can still use the same ID for an iTunes account (to share purchases).
    To create a new icloud account, go to
    http://www.apple.com/icloud/setup/

Maybe you are looking for

  • HP All in One C7280 no longer duplex printing

    I have had my C7280 for over 2 years now and the duplex printing is working fine.  I have checked the control panel printer properties, verified that double sided printing is on for each print in my programs - and still the duplex printing no longer

  • Verizon Mms support for Google voice

    Google voice now supports mms, albeit not in the most graceful fashion.  I ported my number to Google voice as I was a user previously when I was a Sprint customer.  Sprint had native Google voice integration and it is great!  I was simply fed up wit

  • Making graphics

    Hi! I`m very beginner and I would like to know how can I make models?For example a cube,which I can move in the program?Where can I read about this.I don`t understand the official articles.I use j2sdk1.4.2_08 .Thanks for all help.

  • Node Manager Not Starting Managed Servers

    I have nodemanager configured to restart managed servers automatically upon reboot but when I physically restart the 2nd node none of the managed servers start and there are no errors. Steps completed and verified.... 1) Nodemanager.properties has do

  • Aggregate Problems?

    Hello Im using SAP BI 7.0 using WebReports For example: - Characteristic - "SHOP" - Key - Plan1, Last_year, This_Year, Value I have this problem: 1) Without Aggrates my informations is like SHOP |||| Plan1| Last_year | This_year | Vaule | Italy 500 4