Loading an image in from a file

Hi,
I am trying to load an image in from a file, I have found an example using the following code:
import java.awt.Image;
import java.awt.Toolkit;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public final class MainClass {
  private MainClass() {
  public static Image getImage(Class relativeClass, String filename) {
    Image returnValue = null;
    InputStream is = relativeClass.getResourceAsStream(filename);
    if (is != null) {
      BufferedInputStream bis = new BufferedInputStream(is);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      try {
        int ch;
        while ((ch = bis.read()) != -1) {
          baos.write(ch);
        returnValue = Toolkit.getDefaultToolkit().createImage(
            baos.toByteArray());
      } catch (IOException exception) {
        System.err.println("Error loading: " + filename);
    return returnValue;
}Is this a good way of doing it? I want to load a series of images in from files, so I can later do a comparison against them. I am just wondering how to go about the whole process?
Many thanks, Ron

Can you store multiple images in memory and be able
to reference them all individually, or is it better
to store them in a construct, such as an array and
then loop through that when attempting to match?I'm sorry but I don't understand the question. And does it
have anything to do with images per se? Can it be generalized
without losing its meaning:
Can you store multiple objects in memory and be able
to reference them all individually, or is it better
to store them in a construct, such as an array and
then loop through that when attempting to match?It seems to me that multiple objects should be stored in
an appropriate collection, if that is what is required.
Perhaps you need to say more about what you are trying to
do, what your goal is, to make your question meaningful.

Similar Messages

  • I want to load a sales order from xml file. How can I do.

    Hi,
    I want to load a sales order from XML  file. How can I do ? how can i create the sales order?
    what are the necessary  setting for  create the sales orders.
    with Regards,
    Prakesh.

    Three options come to my mind.
    Option 1: Use SAP transaction SXDA_TOOLS (Object Type BUS2032), Program Type (BAPI) and Program (CREATEFROMDAT2).
    Option 2: Use SAP transaction SXDA_TOOLS (Object Type BUS2032), Program Type (DINP) and Program (RVINVB10).
    Option 3: Translate the xml to IDoc so that ORDER04 / ORDER05 Idoc can be used to create Sales order (WEDI transaction).

  • How to load date and time from text file to oracle table through sqlloader

    hi friends
    i need you to show me what i miss to load date and time from text file to oracle table through sqlloader
    this is my data in this path (c:\external\my_data.txt)
    7369,SMITH,17-NOV-81,09:14:04,CLERK,20
    7499,ALLEN,01-MAY-81,17:06:08,SALESMAN,30
    7521,WARD,09-JUN-81,17:06:30,SALESMAN,30
    7566,JONES,02-APR-81,09:24:10,MANAGER,20
    7654,MARTIN,28-SEP-81,17:24:10,SALESMAN,30my table in database emp2
    create table emp2 (empno number,
                      ename varchar2(20),
                      hiredate date,
                      etime date,
                      ejob varchar2(20),
                      deptno number);the control file code in this path (c:\external\ctrl.ctl)
    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime, ejob, deptno)this is the error :
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 5
    C:\>any help i greatly appreciated
    thanks
    Edited by: user10947262 on May 31, 2010 9:47 AM

    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime, ejob, deptno)Try
    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime "to_date(:etime,'hh24:mi:ss')", ejob, deptno)
    this is the error :
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 5
    C:\>
    That's not an error, you can see errors within log and bad files.

  • How to extract text and image information from postscript file

    I want to write a programe,and extract text and image information from postscript file using Java.Is it possible? How to extract ?
    Thank!

    First of all, PostScript is not a "text" file. It can and often does contain binary data. Since PostScript streams often contain nested procedures, unless you process the procedure definitions and can "execute" them, you cannot simply "scan" a file to get what you want. No, I can't talk about this in detail since it is quite complex. But Adobe does have the
    PostScript Language Reference Manual on-line for download at
    . Look that over and you will have a fairly healthy respect as to the task involved.
    - Dov

  • Trying to load a javascript link from text file into a dynamic textfile

    Can anyone help me with this problem? Im trying to load in a
    newsfeed from freshcontent.net into my text field. If i put this
    javascript link on an html page, the page shows correctly, which is
    im supposed to get 3 dynamic links with news content headlines.
    Please view the link to see what i mean:
    http://www.freshcontent.net/directory/real-estate/real_estate.html
    Now, i cannot get this same type of display behavior in my
    text field if i just paste into my text file the javascript link
    thats supposed to bring up the 3 headlines. It is my understanding,
    that flash cannot do this without some sort of specific
    actionscripting, that involves asfusion, and/or externalInterface.
    Im not sure exactly how to go about setting this up to make this
    work. My current code looks like this:
    If anybody could tell me where im going wrong and what i
    should change in order to get the desired result im going for, Id
    very much appreciate it. Thanks

    well sorry there fanmap - but I don't think you're going to
    be able to get this to work. here's why: the link points to a php
    file - which gathers dynamic info from a DB - the return from the
    php is generating a string that is based on the DOM and
    'constructs' a javascript method that in turn writes to the html
    document. although we can embed html into a textField in Flash
    there are a limited number of supported html tags - and JS methods
    will not operate internally. in addition, (i'm not certain someone
    correct this if i'm off) there's no way to 'change' the output of
    the php call, therefore you will not be able to read the return
    because it is designed to use the DOM and write solely to the
    current document. Even if you were to access the JS method from the
    swf file (which one can) it will still only write the content of
    the php return to the html document - and the output is not
    compatible with the textField class.

  • Dynamically loading binary image of report source file

    Post Author: ChristopherZ1
    CA Forum: .NET
    I have stored all my .rpt files as varbinary images in a SQL 2005 DB.  I can retrieve the image write it to disk then load the report. i.e.
    Private m_RptDoc As New ReportDocument()
    m_RptDoc.Load(RptPathName). 
    My question is...is there a way to load the image directly into the ReportDocument without first writting it to disk and using the pathname?

    I would think that this crummy custom Image class hack would work, but surprise surprise -- the width/height in loaderInfo is flat out WRONG when the event fires. It seems to have a hard coded width/height no matter what the file size. Silly!
    <mx:Image xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
         <mx:Script>
              <![CDATA[
                   public function init():void {
                        this.addEventListener(Event.COMPLETE, loaded);
                   private function loaded(e:Event):void {
                        this.width = this.loaderInfo.width;
                        this.height = this.loaderInfo.height;
              ]]>
         </mx:Script>
    </mx:Image>
    Turns out, this version DOES work (but it's still a hack fix in my opinion):
    <mx:Image xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
         <mx:Script>
              <![CDATA[
                   public function init():void {
                        this.addEventListener(Event.COMPLETE, loaded);
                   private function loaded(e:Event):void {
                        this.width = this.contentWidth;
                        this.height = this.contentHeight;
              ]]>
         </mx:Script>
    </mx:Image>
    You guys at Adobe are so silly.    It would seem to me that Image's width and height should be set (rather than left at 0) once the content's width and height is known.  So now that I've fixed this bug (as far as I'm concerned) for ya Adobe, I take cash, cashier's check, or money orders--thanks!
    But really, if this doesn't work this way in Flex 4, I think it should.

  • Help! Read raw Image data from a file and display on the JPanel or JFrame.

    PLEASE HELP, I want to Read Binary(Raw Image)data (16 bit integer) from a file and display on the JPanel or JFrame.

    Hey,
    I need to do the same thing. Did you find a way to do that?
    Could you sent me the code?
    It's urgent, please.
    My e-mail is [email protected]

  • Read Binary(raw Image) data from a file

    Hi
    PLEASE HELP, I want to Read Binary(Raw Image)data (16 bit integer) from a file and display on the JPanel or JFrame.

    Hi, you'll need to use MemoryImageSource.
    You read each RGB triple and add it to a pixel[].
    Heres the roughg idea.
    Hope that helps.
    Harley.
    int width,height;
    int[] pixels = new int[width*height];
    while(!fileDone)
    for(int i=0; i<(width*height) i++){
    int rgb = inputStream.readInt();
    pixels[i] = rgb;
    DirectColorModel colorModel = new DirectColorModel(16,0xff00,0x00ff,0x00ff);
    MemoryImageSource memImage = new MemoryImageSource(width,height,pixels,0,width));

  • Loading hirarchy master data from flat file to BW

    hai,
    i am new to BW Environment, thanks in advance for the Forum.
    while loading hierarchy master data from the flat file to BW, i am getting an error as follow
    WITH AN OPEN SQL SELECT, THE OUT PUT AREA USED TO HOLD THE SELECTED RECORDS MUST BE ATLEAST AS WIDE AS THE DATABASE TABLE FROM WHICH RECORDS ARE BEING READ.
    IN THIS CASE , THE DATABASE TABLE IS 167 BYTES WIDE, BUT THE OUT PUT AREA IS ONLY 141 BYTES WIDE
    pl's any one can help how to solve this problem.
    Thanks in advance to the Forum.
    regards
    Reddy

    Hi,
    This is the procedure.
    1. Create m-data with or without attributes.
    2. Create infosource .
        a) with flexible update
             or
        b) with direct update
    3. Create transfer rules and assign tyhe names of m-data and attribute in "Transfer rules" tab and transfer them to communication structure.
    4. Create the flat-file with same stucture as communication structure.
    5. if chosen direct update then create infopackage and assign the name of flat-file and schedule it.
    6. if chosen flexible update the create update rule with assigning name of the infosource and the schedule it by creating infopackage.
    Hope this helps. If still have prob then let me know.
    Follow this link also.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b2/e50138fede083de10000009b38f8cf/frameset.htm
    Assign points if helpful.
    Vinod.

  • IMAQ image to array vi not working with images extracted from avi file

    Hi,
      I downloaded some avi's and uncompressed them so that I can analyze them within labview. I am trying to convert images I am reading from the avi file to an array. When I use "IMAQ image to array" I get the following error " IMAQ Image To Array  Invalid image type" -1074396080.
       I am able to display each read image and save them to the hard drive, but I am unable to convert the vision image to array. I verified that the image extracted from avi is the same as the image type I created in memory to hold the image.
      Please see the attached vi I created.
    thank you
    Ruz
    Attachments:
    example2.vi ‏62 KB

    Hi all, this thread was useful for me...but i have another doubt... when I try to extract a single plane (Luminance, Saturation, R,G,B...anyone) and try to save it in jpg as gray image, it saves an image with blue tones. I have examinated it using Matlab and checked that Red plane has low values (but not zero), the same for G plane and high values for B plane. An image of the VI is attached.
    Thanks in advance
    Attachments:
    planes.png ‏28 KB

  • I use Windows XP. The problem now is that on two consecutive occasions when I open iTunes it either says the library is corrupt and creates a new one or will not load a previous one from the file. All my meta data and 2K  songs are "missing".

    Can I recreate my proper library with its 8700+ songs and a load of meta data from the iPod. Since two upgrades ago iTunes, for me, has become very unreliable.

    Hi there caunsall!
    I have an article for you that can help you re-create your iTunes library. That article can be found right here:
    iTunes: How to re-create your iTunes library and playlists
    http://support.apple.com/kb/ht1451
    That article will walk you through all the steps to take care of re-creating your library. Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • Image processing from .txt file onto an intensity graph

    I am doing a mini project in my class and I was wondering if anyone could help me. It about image processing but I am bit stuck.
    Heres the idea:
    "An image is really nothing more than a 2D array of data. The value of every element in the array corresponds to the brightness of the image at that point.
    In this project you will create a VI which loads a 2D array of data and then displays it on the screen using the Intensity Graph. Three example files (boats.txt, gordon.txt and parrot.txt) are available on the module webpage that you can use. However, you can also use any other black and white image you like, but will need to convert it to a “text image” first. To do this you can use some software called “ImageJ” which is available on the computers and is free to download.
    You can vary the brightness of an image by adding the same value to every element in the array.
    The contrast of an image is adjusted by multiplying every element in the array by the same value. Using numerical controls and simple array mathematics, you should adjust the brightness and contrast of your displayed image.
    Some other ideas that you could try with image manipulation are:
    o Invert an image (change black to white and white to black)"
    First I am having problems putting my picture onto the graph. It is in the write file but the colours are not correct and the image has rotated 90 degrees. I will upload my VI so far when I get back onto my computer.
    Would really appricate the help! Thank you for reading

    Hi charlthedancer,
    Here is an example to get you started.
    Kind regards,
    GajanS
    Attachments:
    Test.vi ‏14 KB

  • Load to ODS failed from flat file

    Hi Gurus,
    We have 4 flat files to be loaded in the ODS.And this ODS is giving the data as an delta to upper ODS. 3 got loaded correctly.But the 4th load was taking too much time.In RSMO request was Yellow for a long time.After some time Request became Red giving an error as follows.
    Processing in Warehouse timed out; processing steps mising
    Diagnosis
    Processing the request in the BW system is taking a long time and the processing step Update rules has still not been executed.
    System response
    <DS:DE.RSCALLER>Caller  is still missing.
    Procedure
    Check in the process overview in the BW system whether processes are running in the BW system under the background user.
    If this is not the case, check the short dump overview in the BW system.
    Can anyone explain me what is the meaning of this error ?
    As a corrective action., I tried to reconstruct the request from PSA, but reconstruction also failed.But the PC turned to GREEN and got completed.i.e. Data Mart Status set for these 3 requests.
    Now this request is showing status as RED in the Manage Tab And it has 3 successfully loaded requests above it.
    I want to have this 4th request to get updated in lower ODS and also delta to be pushed in to upper ODS.
    Kindly tell me what should I do?

    Hi,
    Go to Details tab in monitoring.
    Just check for any packages are in yellow.
    If any package i yellow then right click and take the Update manually option for that package only.
    Or else you have to delete the request from the target and make the request in to red in monitor under Status tab.
    Now you can try to load the data.
    This is because of IDocs not processed successfully.
    Regards,
    Venkat

  • Loading data for heirarchies from flat file.

    Hi,
    I am trying to load heirarchies from a flat file. I am getting the error "Error during the calculation at the node level".
    I am not able to get the reason.I am also scpetical about this
    1.Is it necessary that the external characterics whic are used in heirarchy should already contain data?
    2.Should we create a root node before loading the data? Or will it create everything itself during the loading.
    3. Should this heirarchies be created directly on the productive system.
    regards
    Mandha

    Hi,
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/fa/e92637c2cbf357e10000009b38f936/frameset.htm
    GTR

  • Images:  displaying from the file system

    I have the instructions for loading images into a database column. However, for my prototype, I want to read leave the images in the file system and store the filenames in the database. Then I want to create a form to display the images in an 'art gallery' kind of format, like a column for the picture, a column for a description, and column for a checkbox, so the user could say 'I want this one, this one, and this one.' What's the best approach for this kind of thing?

    Have you looked at the sample application? I think it has a table just like that, I don't have it installed anywhere anymore, so don't know off the top of my head.
    One way is
    your pictures table would have a format like:
    ID, PICTURE_NAME, DESCRIPTION
    your report is then:
    select htmldb_item.display_and_save(1, id) id,
    '< img src = "/i/your_directory "'|| picture_name ||' " < /img > ' picture,
    htmldb_item.checkbox...

Maybe you are looking for

  • E90 Using Nokia Maps without using Data from mobil...

    Is it possible to use the integrated GPS in the E90 with Nokia Maps WITHOUT connecting through mobile data and incurring data cost? Is there any other 3rd party GPS navigation software that would work like Nokia Maps, using stored maps et al, so you

  • Pages is selecting different fonts?

    I downloaded a bunch of fonts and they worked for a while but then when i tried to load up pages or word and select "times" it came up with a completely random font that was downloaded. I re loaded it and it does the same thing. Please help. I need t

  • How would I implement a SlotQueue in java?

    I am currently writing a MUD server in Java and I use Jython scripting to make everything dynamic however there is one drawback with that.. exec() eval() and execfile() are very very expensive so I created a series of worker threads that run and stay

  • Apex SSL from  HTTP server - err 29040

    Have apex environment (originally 3.1.2 now 3.2) workiing fine under http server 10.1.3. regular http port 7777. After going thru the ssl and wallet documentation steps to apply certificates supplied to me, and scouring all the blogs, I'm still faili

  • Bad battery, flash blinds camera and lock button broke within 2 weeks. What to do?

    The battery was terrible when I first got the phone, it's improved a little but still nothing campred to my 3G. The camera's flash whites out the screen, seems either a fault of my phone or badly tested. Does anyone else get this? And, my lock button