How to Load an image into buffered image then drawString()?

HELP , i need to load image for the background called noise.png
I want to load the noise.png as the background of the new generated image .
How suppose that i can do that ?
This is my code with a Black color background
public static String createViverificationImageAtPath(String path,int width, int height) throws IOException {
        String out = "";
        java.awt.image.BufferedImage bi = new java.awt.image.BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
        bi.setRGB();
        String viver = (int)((float)Math.random() * 100000) + "";
        viver = generate.getRandomRomanLetter(false) + viver + generate.getRandomRomanLetter(false);
        Graphics2D g2d =  bi.createGraphics();
       // g2d.setColor(Color.blue);
        g2d.setBackground(Color.yellow);
        g2d.drawString(viver,3,height - 5);
        g2d.drawLine(0,height,width,0);
        ImageIO.write(bi,"jpeg",new File(path));
        return viver;
    }

ImageIO.load()
you know, the opposite of save?

Similar Messages

  • How to load an image into blob in a custom form

    Hi all!
    is there some docs or how to, load am image into a database blob in a custom apps form.
    The general idea is that the user has to browse the local machine find the image, and load the image in a database blob and also in the custom form and then finally saving the image as blob.
    Thanks in advance
    Soni

    If this helps:
    Re: Custom form: Take a file name input from user.
    Thanks
    Nagamohan

  • How to load a image after getting it with a file chooser?

    I'm still starting with JavaFX, and I simply would like to know how to load the image (e.g. png or jpg) that I selected using a FileChooser in the user interface. I can access the file normally within the code, but I'm still lost about how to load it appropriately. Every time I select a new image using the FileChooser, I should discard the previous one and consider the new one. My code is shown below:
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.paint.Color;
    import javafx.scene.layout.HBox;
    import javafx.scene.control.Button;
    import javax.swing.JFileChooser;
    import javafx.scene.image.ImageView;
    import javafx.scene.image.Image;
    var chooser: JFileChooser = new JFileChooser();
    var image;
    Stage {
        title: "Image"
        scene: Scene {
            width: 950
            height: 500
            content: [
                HBox {
                    layoutX: 670
                    layoutY: 18
                    spacing: 10
                    content: [
                        Button {
                            text: "Open"
                            action: function() {
                                if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(null)) {
                                    var imageFile = chooser.getSelectedFile();
                                    println("{imageFile.getCanonicalFile()}");
                                    image = Image{
                                        width: 640
                                        url:imageFile.getAbsolutePath()
                // Image area
                Rectangle {
                    x: 10
                    y: 10
                    width: 640
                    height: 480
                    fill: Color.WHITE
                ImageView {
                    x: 10
                    y: 10
                    image: bind image
    }Thank you in advance for any suggestion to make it work. :)

    As its name implies, the url param expect... an URL, not a file path!
    So, use {color:#8000FF}url: imageFile.toURI().toURL(){color} instead.

  • How to load mutiple image

    I'm trying to create a photo manager but I can't find a way to load multiple images onto my frame. I have a thumbnail class that makes thumbnails for an image (which is a modified version of the class ImageHolder from FilthyRichClient)
    public class Thumbnails {
         private List<BufferedImage> scaledImages = new ArrayList<BufferedImage>();
    private static final int AVG_SIZE = 160;
    * Given any image, this constructor creates and stores down-scaled
    * versions of this image down to some MIN_SIZE
    public Thumbnails(File imageFile) throws IOException{
              // TODO Auto-generated constructor stub
         BufferedImage originalImage = ImageIO.read(imageFile);
    int imageW = originalImage.getWidth();
    int imageH = originalImage.getHeight();
    boolean firstScale = true;
    scaledImages.add(originalImage);
    while (imageW >= AVG_SIZE && imageH >= AVG_SIZE) {
         if(firstScale && (imageW > 320 || imageH > 320)) {
              float factor = (float) imageW / imageH;
              if(factor > 0) {
              imageW = 320;
              imageH = (int) (factor * imageW);
              else {
                   imageH = 320;
                   imageW = (int) (factor * imageH);
         else {
              imageW >>= 1;
         imageH >>= 1;
    BufferedImage scaledImage = new BufferedImage(imageW, imageH,
    originalImage.getType());
    Graphics2D g2d = scaledImage.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2d.drawImage(originalImage, 0, 0, imageW, imageH, null);
    g2d.dispose();
    scaledImages.add(scaledImage);
    * This method returns an image with the specified width. It finds
    * the pre-scaled size with the closest/larger width and scales
    * down from it, to provide a fast and high-quality scaled version
    * at the requested size.
    BufferedImage getImage(int width) {
    for (BufferedImage scaledImage : scaledImages) {
    int scaledW = scaledImage.getWidth();
    // This is the one to scale from if:
    // - the requested size is larger than this size
    // - the requested size is between this size and
    // the next size down
    // - this is the smallest (last) size
    if (scaledW < width || ((scaledW >> 1) < width) ||
    (scaledW >> 1) < (AVG_SIZE >> 1)) {
    if (scaledW != width) {
    // Create new version scaled to this width
    // Set the width at this width, scale the
    // height proportional to the image width
    float scaleFactor = (float)width / scaledW;
    int scaledH = (int)(scaledImage.getHeight() *
    scaleFactor + .5f);
    BufferedImage image = new BufferedImage(width,
    scaledH, scaledImage.getType());
    Graphics2D g2d = image.createGraphics();
    g2d.setRenderingHint(
    RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2d.drawImage(scaledImage, 0, 0,
    width, scaledH, null);
    g2d.dispose();
    scaledImage = image;
    return scaledImage;
    // shouldn't get here
    return null;
    A loop will loop through a collection of files and pass them to the constructor of Thumbnails to create thumbnails and then set them as icon for JLabels that will be added to a JPanel, but it throws a java.lang.OutOfMemoryError at this line:
    BufferedImage originalImage = ImageIO.read(imageFile);
    even when there're only about 8 image files in the collection (total size 2,51MB).
    I've seen other people's software that could load hundreds of photos in a matter of seconds! How do I suppose to do that? How to load mutiple images efficiently? Please help!! Thanks a lot!

    another_beginner wrote:
    Thanks everybody! I appreciate your help! I don't understand why but when I use a separate thread to do the job, that problem disappear. You were likely doing your image loading and thumnail creation on the Event Dispatching Thread. Among other things, this is the same thread that updates and paints your panels, frames, buttons, ect.. When a programer does something computationaly expensive on the event dispatching thread then the GUI becomes unresponsive until the computation is done.
    Ideally what you want to do is load images and create thumnails on a seperate thread and update your GUI on the event dispatching thread. I supect that while you are finally doing the first item, you might now be violating the second item.
    Whatever, the program seems to be pretty slow on start up 'cause it have to reload images everytime. I'm using Picasa and it can display those thumbnails almost instantly. I know that program is made by professionals. But I still want to know how.I took a look at this Picasa you mentioned. It's the photo manager from google right? You're right in that the thumnails display instantly when starting up. This is because Picasa is actually saving the thumnails, instead of creating them everytime the program starts up. It only creates the thumnails once (when you import a picture) and saves the thumnail data to " +*currentUser*+ /AppData/Local/Google/Picasa2/db3/" (at least on my computer --> Vista).
    Also, if your looking for speed then for some inexplicable reason java.awt.Toolkit.getDefaultToolkit().createImage(...); is faster (sometimes much faster) than ImageIO.read(...). But there comes a price in dealing with Toolkit images. A toolkit image isn't ready for anything until it has been properly 'loaded' using one of several methods. Also, when you're done and ready for the image to be garbage collected then you need to call Image.flush() or you will eventually find yourself with an out of memory error (BufferedImages don't have this problem). Lastly, Toolkit.createImage(...) can only read image files that the older versions of java supported (jpg, png, gif, bmp) .
    And, another question (or maybe I should post it in a different thread?), I can't display all thumbnails using a JPanel because it has a constant height unless I explicitly set it with setPreferredSize. Even when put in a JScrollPane, the height doesn't change so the scrollbar doesn't appear. Anyone know how to auto grow or shrink a JPanel vertically? Or I have to calculate the preferred height by myself?Are you drawing the thumnails directly on the JPanel? If so then you will indeed need to dynamically set the preferred size of the component.
    If not, then presumebly your wrapping the thumnails in something like a JLabel or JButton and adding that to the panel. If so, what is the layout manager you're using for the panel?

  • Step- by- Step on How to Load Excel data into Crystal Reports?

    Hi Friends,
                      Can anyone send me a Step- by- Step on How to Load Excel data into Crystal Reports? Pls help me. Thanks in Advance.
    Vijay

    It's also important to 'prep' the excel file prior to connecting to it.
    Give the data tab a meaningful name
    Make sure the column headers are unique and that every column has a header
    Delete any blank tabs
    If you have trouble with Excel changing the data type of a field (say, a social security number you want to be a string value rather than a number so you don't lose leading zero) an alternative would be to save the spreadsheet file as a CSV, create a schema.ini to specify the data types for each column (example below) and use the same steps to connect except instead of choosing Excel 8.0, scroll to the bottom and choose Text.  You have to make sure the CSV file is in the same folder as the schema.ini file that defines the columns.
    Schema.ini example:
    200912PUSD.csv
    ColNameHeader=True
    Format=CSVDelimited
    MaxScanRows=25
    CharacterSet=OEM
    Col1=SSN Char Width 9
    Col2=LAST_NM Char Width 25
    Col3=FIRST_NM Char Width 25
    Col4=DOB Date
    Col5=STDNT_ID Char Width 10
    Col6=SORTKEY Char Width 10
    Col7=SCHOOL_NM Char Width 30
    Col8=OTHER_ID Integer
    Col9=GRADE Char Width 2
    The filename in the first line needs to have the []  brackets around it, but I couldn't get it to display in this forum correctly.
    Edited by: Eric Petersen on Jan 27, 2010 9:40 AM

  • How to load oracle data into SQL SERVER 2000?

    how to load oracle data into SQL SERVER 2000.
    IS THERE ANY UTILITY AVAILABLE?

    Not a concern for an Oracle forum.
    Als no need for SHOUTING.
    Conventional solutions are
    - dump the data to a csv file and load it in Mickeysoft SQL server
    - use Oracle Heterogeneous services
    - use Mickeysoft DTS
    Whatever you prefer.
    Sybrand Bakker
    Senior Oracle DBA

  • *** Question How to load a file into BI-Integrated Planning and use WAD 7.0

    Hi, I created an manual DTP upload to my planning infocube and it works fine.  The transformation rules convert 0CALMONTH into the relevant Calendar and Fiscal characteristics.   So all of my Time Characteristics are fine, both Calendar and Fiscal.
    However, When using the "How to load a file into BI-Integrated Planning and use WAD 7.0" solution, only the Calendar Characteristics are populated and not the Fiscal.   The upload application somehow knows to populate the 0CALMONTH2, 0CALQUART1, 0CALQUARTER, and 0CALYEAR.  
    How can I get the upload to populate my Fiscal Period Characteristics?
    Would it be best to modify the "Upload Application, or can I write a planning function to update the fiscal characteristics, or some other way?
    Thanks!

    My planning data is being uploaded via the SDN Planning File Upload Solution. What I did was end up modifiying the upload class ZCL_RSPLF_FILE_UPLOAD Method EXECUTE.
    I added the following code if anyone is interested.
    *{ INSERT BWDK902323 1
    THIS SECTION OF CODE POPULATES THE FISCAL PERIOD CHARACTERISTICS
    USING THE FISCAL YEAR VARIANT 'NK' AND THE CALENDAR MONTH/YEAR
    FIELD-SYMBOLS <0FISCVARNT> TYPE /BI0/OIFISCVARNT. " Fiscal Year Variant
    FIELD-SYMBOLS <0FISCYEAR> TYPE /BI0/OIFISCYEAR. " Fiscal Year
    FIELD-SYMBOLS <0FISCPER> TYPE /BI0/OIFISCPER. " Fiscal Year/Period
    FIELD-SYMBOLS <0FISCPER3> TYPE /BI0/OIFISCPER3. " Posting Period
    FIELD-SYMBOLS <0CALMONTH> TYPE /BI0/OICALMONTH. " Calendar Month/Year
    ASSIGN COMPONENT '0CALMONTH' OF STRUCTURE <L_S_DATA> TO <0CALMONTH>.
    ASSIGN COMPONENT '0FISCPER' OF STRUCTURE <L_S_DATA> TO <0FISCPER>.
    ASSIGN COMPONENT '0FISCVARNT' OF STRUCTURE <L_S_DATA> TO <0FISCVARNT>.
    ASSIGN COMPONENT '0FISCPER3' OF STRUCTURE <L_S_DATA> TO <0FISCPER3>.
    ASSIGN COMPONENT '0FISCYEAR' OF STRUCTURE <L_S_DATA> TO <0FISCYEAR>.
    <0FISCVARNT> = 'NK'.
    CALL FUNCTION 'FISCPER_FROM_CALMONTH_CALC'
    EXPORTING
    IV_CALMONTH = <0CALMONTH>
    IV_PERIV = <0FISCVARNT>
    IMPORTING
    EV_FISCPER3 = <0FISCPER3>
    EV_FISCPER = <0FISCPER>
    EV_FISCYEAR = <0FISCYEAR>.
    *} INSERT

  • Uregnt - How to Load Flat File into BW-BPS using Web Browser

    Hello,
    We have followed the 'How to Load Flat File into BW-BPS using Web Browser' guide to build BSP web front-end to upload flat file.  Everything works great but we have a requirement to populate the Planning Area Variables based on BSP drop down list with values.  Does anyone know how to do this?  We have the BSP coded with drop down list all we need to do now is populate variables.  We can populate the variables through the planning level (hardcoded) but we need to populate them through the web interface.
    Thanks,
    Gary

    Hello Gary,
    We have acheived the desired result by not too a clean method but it works for us.
    What we have done is, we have the link to load file in a page where the variables can be input. The user would then have the option to choose the link to load a file for the layout in that page.
    By entering the variable values in the page, we are able to read the variables for the file input directly in the load program.
    Maybe this approach might help.
    Sunil

  • How to load flat file into BW BPS

    hi,
    how to load flat file into BW BPS ?

    Have a read through this;
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/g-i/how%20to%20load%20a%20flat%20file%20into%20bw-bps%20using%20a%20web%20browser.pdf

  • Can anyone tell me how to load an image to custom shape in Photoshop? I can't save it as csh...

    I've made an image, as the watermark of our photos, but I can't load it to Custom Shape in PS CS4 as I can't save it as csh. Do you know how to upload an image type file that is not csh? Or how to convert the image to csh? Thanks.

    As Chris says, you can't make it into a custom shape unless you create it as a path. But you can save it as a Custom Brush (in monochrome).

  • How to load jpeg images in database?

    I have an employees panel and it has a box to show employee's picture. Normally I double click on the box and it takes me to the folder where I have stored all employees jpeg file. I click on the one I need and then insert, it shows up on the panel and also saving the data in a table called PS_EMPLOYEE_IMAGE table.
    If I want to insert number of images at one time thru the back end like sqlplus is there a way to do it? This saves me lot of time instead of entering thru the panel. Can it be done? For example fot employee1 insert jpeg1, employee2 jpeg2 etc. DO I have to use any tool to convert these jpeg files into some other data and then insert it? Is there any pl/sql package to do it?. If some one can explain me with simple explanation I really appreciate as I am not an real oracle person. Googling for this issue says it can be done but it is not very clear in steps of doing it.

    Thanks for your help. I did exactly like what you described (see below)
    1) I created a image_file.txt file as shown below
    EMPLID|EFFDT|EFF_STATUS|IMAGE_FILE
    100000|08-FEB-2011|A|H:\SQL_Loader\George_Test.jpg
    100001|08-FEB-2011|A|H:\SQL_Loader\Eftihia_Test.jpg
    2) Then created EE_Image_Tbl.ctl file as shown below.
    OPTIONS (DIRECT=TRUE, SKIP=1)
    UNRECOVERABLE
    LOAD DATA
    APPEND
    INTO TABLE PS_EMPLOYEE_IMAGE
    FIELDS TERMINATED BY '|'
    (EMPLID
    ,EFFDT
    ,EFF_STATUS
    ,IMAGE_FILE FILLER CHAR(80)
    ,EE_IMAGE LOBFILE(IMAGE_FILE) TERMINATED BY EOF)
    3) then used the sql loader (load_ee_image.sql)
    $ sqlldr DH5M/ep5evs1@KDH5MI01 control=h:\sql_loader\EE_Image_Tbl.ctl log=h:\sql_loader\load_ee_image.log data=h:\sql_loader\image_file.txt
    SQL> --*
    SQL> commit;
    Commit complete.
    SQL> --*
    SQL> @h:\sql_loader\load_ee_image.sql;
    SQL> $ sqlldr DH5M/ep5evs1@KDH5MI01 control=h:\sql_loader\EE_Image_Tbl.ctl log=h:\sql_loader\load_ee_image.log data=h:\sql_loader\image_file.txt
    SQL> --*
    SQL> --*
    SQL> --*
    SQL> commit;
    Commit complete.
    SQL> --rollback;
    SQL> --*
    SQL> spool off
    L
    Number to skip: 1
    Errors allowed: 50
    Continuation: none specified
    Path used: Direct
    Load is UNRECOVERABLE; invalidation redo is produced.
    Table PS_EMPLOYEE_IMAGE, loaded from every logical record.
    Insert option in effect for this table: APPEND
    Column Name Position Len Term Encl Datatype
    EMPLID FIRST * | CHARACTER
    EFFDT NEXT * | CHARACTER
    EFF_STATUS NEXT * | CHARACTER
    IMAGE_FILE NEXT 80 | CHARACTER
    (FILLER FIELD)
    EE_IMAGE DERIVED * EOF CHARACTER
    Dynamic LOBFILE. Filename in field IMAGE_FILE
    SQL*Loader-418: Bad datafile datatype for column EE_IMAGE
    This is becasue my image datatype can be declared as LONG RAW dara type thru my application.
    When I created a table with image datatype as BLOB it worked.
    But I want to insert into the existing table where image is declared as LONG RAW. How to insert jpeg into this field. Do I have to convert anything? Thx.
    Edited by: user5846372 on Feb 8, 2011 1:18 PM
    Edited by: user5846372 on Feb 8, 2011 2:16 PM

  • How to load a image from database to image item in oracle 10 g form

    I have stored some images in the Database Table with BLOB datatype. Now I need to load that image in the non database image item. Please advise. Thanks.

    You need to have a print server installed to generate the pdf. Either use BI Publisher and it's desktop development tool or use FOP/Cocoon.. Adding an image with them is a little more involved..
    Thank you,
    Tony Miller
    Webster, TX
    While it is true that technology waits for no man; stupidity will always stop to take on new passengers.

  • How to load the image on to the Java applet?

    Hey,
    I need help on loading a image to java, I am using Eclipse, I have no idea what class I should use. Please help me thanks

    I found this with search problem with loading images

  • How to load a jpg into my movie ???

    I want to load an image stored on my pc into my swf file. i
    know that i can use the loadMovie() method. but i didnt know how to
    enter the url of the target file. For example i have the file in
    the following directory - C:\Documents and Settings\Admin\My
    Documents\image.jpg - how can i load this file into my movie ???
    and THANX...

    aha, ok now i have a problem in duplicating nested movie
    clips. like if i have made a movieclip using the code (lets name it
    OUTSIDE) and another one inside(lets name it INSIDE) it, when i
    duplicate the movieclip OUTSIDE the INSIDE one doesnt exist in the
    new copy. i think the reason is something related to the depth but
    i'm not sure where is the problem. here is an example:
    this.createEmptyMovieClip("line",this.getNextHighestDepth());
    line.createEmptyMovieClip("lineIn",this.getNextHighestDepth());
    line.lineIn.lineStyle(10);
    line.lineIn.lineTo(100,100);
    line.duplicateMovieClip("line2",this.getNextHighestDepth());
    line2._x = 150;
    when i duplicate the the movieclip (line), the movieclip
    (lineIn) doesnt exist inside the new copy which is (line2)

  • How to load firmware maualy into 7960 Phone

    All,
    First of all , forgive my silly question.
    Is there any way to load the firmware unzipped file(cmterm-7940-7960-sccp.8-0-8.zip) into a 7960 IP Phone without having to access to a CCM or TFTP server? An alternative Cisco CallManager is not available to run the executable installer program and the IP phone is MGCP and need to load SCCP firware into it.
    Thnaks a lot in advance .
    Regards,
    Maddox

    Wow
    Now i need a points for this please rate.
    Ok i will explain you this how it works
    First you will be require xml file while u have to get it when u make router as a CME server.
    Just configure router as a CME server by telephony-service setup do any configuration once done to the last step it will create a xml file copy that xml file to one folder and open the same.
    Now go to CCM server and check CCM is using which load through device default load
    Then download the same load from Cisco.com and copy on the same folder where you have kept the xml.txt file open that xml.txt into notepad and try searching the phone model number e.g 7960 once u will find that u will see the load information which is there by default just change the load information parameter to yr load without .load extension
    and save it
    Now on yr ip phone point to yr LP tftp where that u have kept yr folder with xml.txt & firmware.
    It will work without have yr Cisco Call Manager it will update the same firmware image.
    If someone have a problem please mail me
    I will help
    THks in advance.

  • How to load XML files into ORACLE8i database?

    SAP data is being extracted into XML format (via IDOC) files which are being transferred to an ORACLE8i box. There will be a large amount of data transferred on a daily basis which will include updates and inserts. From all the information that I have read on this subject there are 2 options available :
    1. XML-SQL Utility - which converts XML into INSERT, UPDATE or DELETE SQL. There does not appear to be that much functionality available by this method for decodes, transformations on the input data.
    2. SQL*Loader - There was a statement in 1 piece of documentation stating that SQL*Loader could be used for loading XML format data files. I cannot however find any further information on how this is achieved or how it works.
    If anyone has any experience in loading XML format data files using either of the above methods (preferably SQL*Loader as it has more functionality) then could you please provide me with examples or guidance on this matter? Any help would be greatly appreciated as I am not familiar with XML format data files. I am from an Oracle 7.3 background but do not have much experience with Oracle 8 onwards.
    Disclaimer.
    Any views expressed in the above paragraphs are my own and not that of Hewlett Packard Ltd.

    We are loading XML into our database using CLOB datatypes. We don't use the XSU for inserts as it is too slow. We parse the incoming XML document into a PL/SQL record type and then build a generic insert. This might not work well if you have many tags to parse into columns. We also store the entire XML CLOB into a column without parsing the individual tags into separate columns. We then use Intermedia Text for fast, index-based searching within the XML column.
    Check out The Oracle XML Portal website for code examples on how to do this:
    www.webspedite.com/oracle

Maybe you are looking for

  • Sub-contracting PR

    Hi,experts, My scenario is like this - I want to send some components to outside vendor for repairing purpose and sometimes along with some spare parts also. My requirement is to create sub-contracting PR from any maintenance order and in the line it

  • My iPhone 5 is not appread in itunes after updating to new itunes software

    Please if any one can help as few days back I updated itunes with new software. after updating, my iPhone 5 is not appearing in tunes.

  • ACPI\HPQ6007

    I have a problem with "ACPI \ HPQ6007" driver in device manager as unknown dipositive me room, I asked if I could pass the driver, is that I can not locate an on the internet and not as out on the page hp. Thanks if you decide to help !  This questio

  • TimeKeeper CLA Issue

    Hi All , I have enabled the CLA functionality at the TimeKeeper Level . Follwing are some of the issues I am encountering : 1) Whenever a change is made by Timekeeper on a approved timecard for a particular day , the timekeeper is forced to enter a c

  • I have google in my menu bar but all I get is a message error

    I am running the latest Firefox under XP with all its updates and have Google search in my menu bar, if I ask it anything a message comes "Secure Connection Failed" along with a reference (error code: ssl_error_rx_record_too_long). I have a homepage