Need to create simple image as byte stream...

I am looking for a simple and efficient mechanism (supported in Java 1.4.x and later) that would allow me to create a simple raster image byte stream (in .png, .gif or .jpeg encoding) given an RGB + Alpha value (Paint?) and x and y dimensions in pixels.
I know it sounds unbelievably trivial, but I haven't played with the image stuff in Java in a long time and I am looking for an easy (read "handed to me on a silver platter") solution.
TIA,
Chuck

I guess I should have looked for myself, but it being Friday and I being lazy I didn't want to bother...
The answer to this question is best rendered in the Java Almanac: http://javaalmanac.com/egs/javax.imageio/Graphic2File.html

Similar Messages

  • I need to create a image using some numeric values and i want to display values in image,

    I need to create a image using some numeric values and i want to display values in image, Numeric values be enterd by text file, excel file or user input by dialog box,
    this is the sample if image.
    http://s17.postimg.org/5xvtzbztn/5_01_03_I.png
    128 x 16 Pixels , Back ground Black, Numbers in Red, Should be same as above picture.
    Because i have hundreds of images to create like this.
    If any one can make a script for this it is very good.
    Sorry about my English.
    Thank you.

    Have you checked out data driven graphics?
    https://helpx.adobe.com/photoshop/using/creating-data-driven-graphics.html

  • I need to create an image gallery

    I'm looking for a tutorial which explains me how to create a simple AS3 image gallery driven by an XML file.
    The gallery I need is really simple:
    - an horizontal bar placed on the bottom containing the thumbnails which scrolls left and right according to the mouse pointer
    - clicking on a thumbnail the full image must be shown above the thumbnails' bar
    - buttons for prev and next image
    - clicking on the button which opens the gallery I must be able to pass a variable to make the gallery load the proper xml file (I've got 6 different categories to show)
    That's all I need.
    Do you know where I could find a tutorial?

    I'm trying to do it by myself.
    I've decided to give to the xml file this structure
    <imgList>
        <img thumb='img_001_thumb.jpg' full='img_001_full.jpg' desc='image 001' />
        <img thumb='img_002_thumb.jpg' full='img_002_full.jpg' desc='image 002' />
    </imgList>
    I've found some tutorials where they read the attributes in this way
    xml.img@thumb
    xml.img@full
    xml.img@desc
    where xml is an xml variable containing the xml file's data.
    I think that syntax is for AS2, while I'm using AS3 and it say to me that a semicolon is expected before atsign.
    How can I read the attributes thumb, full and desc in AS3?

  • Create an image gallery in DW

    Hi all
    I am working on a new website in Dreamweaver.   I am happy to hand code the HTNL and CSS (using what shortcusts are availablel CSS with Designer etc).   As a fairly new subscriber to CC I have been using Lynda.com to the learn DW and found that DW no longer supports SPRY.   I NEED TO CREATE AN IMAGE GALLERY WITHIN THE NEW SITE, but now need to know which adobe product is best to use to create the gallery and embed the appropeiate HTML/CSS etc into the pages using DW???
    I appreciate your help here

    My favorite is Fancybox2....
    It handles anything!
    http://fancyapps.com/fancybox/

  • How do i create an Image in my own class

    Hi!
    I have a class
    public class gBuffer {
    which is used for double and tripple and n-th
    buffer of graphics.
    I need to create an image in the constructor, but
    the only way i could do it is something like:
    Applet a = new Applet();
    Image i=a.createImage(100,100);
    I just could not find any other class where createImage()
    is not abstract.
    How do i do it right?

    You need a real live Component object that will enable
    you to do something like this:
    Component c = get_a_Component_from_somewhere();
    Image writable = c.createImage(100,100);
    Graphics g = writable.getGraphics();
    g.drawxyz(...);
    g.dispose();If you're programming from within an application or servlet,
    with no real GUI components available,
    then you might have a problem. You might create a
    Frame object without ever making it visible.
    -Ken

  • Create an Image

    Hie.. i've browse through the forum to search a solution to my problem but i dont find any resourceful. I hope someone could help me out. Here is the problem :-
    I tried to create an Image using byte of array as such :-
    ** the message is in byte
    currentImage = Image.createImage(message,0,message.length);
    imageItem = new ImageItem("Default", currentImage,
    imageItem.LAYOUT_CENTER,"image");
    But i got this error message :-
    java.lang.IllegalArgumentException:
         at javax.microedition.lcdui.ImmutableImage.<init>(+11)
         at javax.microedition.lcdui.Image.createImage(+40)
         at showReceivedMessage.<init>(+155)
         at Register.displayReceivedMessage(+23)
         at ReceiveMessage.notifyMessage(+279)
         at j.notifyRequest(+391)
         at gov.nist.microedition.sip.SipConnectionNotifierImpl.a(+33)
         at gov.nist.microedition.sip.StackConnector.processRequest(+106)
         at gov.nist.siplite.EventScanner.run(+389)
    I suppose the error message mean i'd had passed an illegal argument for an immutableImage but i already make sure that its all correct yet still get thismessage. Please help as i've look into this for weeks.. :(

    Hi
    It means that your layout value is not legal. Also, try using this instead: currentImage = Image.createImage(message,0,message.length);
    imageItem = new ImageItem("Default", currentImage, 0, "image");Also, you might want to try using ImageItem.LAYOUT_CENTER instead of imageItem.LAYOUT_CENTERMihai

  • Creating an image of a component

    hi
    i'm working on a small applet. i need to create an image of any component (like JLabel) before it is shown on the screen.
    can i do it?

    Try:
    Image getComponentImage(Component comp) {
        BufferedImage imgBuf = new BufferedImage(comp.getWidth(),comp.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
        Graphics gr = imgBuf.createGraphics();
        comp.paint(gr);
        return imgBuf;
    }Graeme

  • How to create simple JSP and deploy to J2EE engine?

    Hi,
    I need to create simple JSP pages and deploy it to SAP J2EE engine.. what is the procedure?...I may later add some businness logic but not needed for now.
    Please help
    Thanks,
    Jai

    Gabrie,
    Here are Simple steps,
    In the NWDS
    1) create J2EE -> Web Module Project    (XYZ)
    2) create/add your JSP pages to the project
    3) Right click on your project root and click on 'Build Web Archive' from the context
    3) create J2EE -> Enterprise Application project(EAR)
    4) Right click on your Web Module Project root and click on 'Add to EAR Project' from the context, select the EAR you just created in step 3.
    5)Right click on your EAR project root and click on 'Build WebApplication Archive' from the context
    6)Expand the EAR project node, and right click on the *.ear file, click on 'Deploy to J2EE Engine'.
    7)Enter your SDM password  when prompted,
    You can access you JSP at this url
    http://server:port/xyz/a.jsp
    - Dileep

  • Thumbnail images, mysql, byte[ ]  - need some help

    I'm using the tech tip found on sun's site for "Creating Image Thumbnails" at http://java.sun.com/developer/TechTips/1999/tt1021.html#tip1
    I've looked over the code, and now I'm trying to mesh some of the code from that example with the code for my servlet program.
    My servlet takes a jpeg image submitted from an html form on a web page (all of which I'm testing on my localhost Tomcat server) and uploads it into my mysql database into a column of type BLOB. I do not upload a reference to a FILE, rather, I upload the BYTES that make up that image.
    I wanted to make the images into a thumbnail size PRIOR to uploading them into the db.
    My code snippet for my servlet that just uploads the file without modifying its size is:
    boolean isPart = FileUpload.isMultipartContent(req);
         if(isPart)
    DiskFileUpload upload = new DiskFileUpload(); // upload a file from the local disk.
    List items = upload.parseRequest(req); // Create a list of all uploaded files.
         Iterator it = items.iterator(); // Create an iterator to iterate through the list.
              while(it.hasNext())
         FileItem item = (FileItem)it.next();
         File f = new File(item1.getName()); // Create a FileItem object to access the file.
    byte[] bytes = new byte[(int)f.length()];
         FileInputStream fs = new FileInputStream(f);
         BufferedInputStream bis = new BufferedInputStream(fs);
         bis.read(bytes);
    PreparedStatement stmt = conn.prepareStatement("UPDATE car SET Image1 = ? where Account=1");
         stmt.setBytes(1, bytes);
         int i = stmt1.executeUpdate();
    Here is the code from the Tech Tip:
    import java.awt.Image;
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.FileOutputStream;
    import javax.swing.ImageIcon;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    class Thumbnail {
    public static void main(String[] args) {
    createThumbnail(args[0], args[
    1], Integer.parseInt(args[2]));
    * Reads an image in a file and creates
    * a thumbnail in another file.
    * @param orig The name of image file.
    * @param thumb The name of thumbnail file.
    * Will be created if necessary.
    * @param maxDim The width and height of
    * the thumbnail must
    * be maxDim pixels or less.
    public static void createThumbnail(
    String orig, String thumb, int maxDim) {
    try {
    // Get the image from a file.
    Image inImage = new ImageIcon(
    orig).getImage();
    // Determine the scale.
         double scale = (double)maxDim/(
         double)inImage.getHeight(null);
    if (inImage.getWidth(
    null) > inImage.getHeight(null)) {
    scale = (double)maxDim/(
    double)inImage.getWidth(null);
    // Determine size of new image.
    //One of them
    // should equal maxDim.
    int scaledW = (int)(
    scale*inImage.getWidth(null));
    int scaledH = (int)(
    scale*inImage.getHeight(null));
    // Create an image buffer in
    //which to paint on.
    BufferedImage outImage =
    new BufferedImage(scaledW, scaledH,
    BufferedImage.TYPE_INT_RGB);
    // Set the scale.
    AffineTransform tx =
    new AffineTransform();
    // If the image is smaller than
    //the desired image size,
    // don't bother scaling.
    if (scale < 1.0d) {
    tx.scale(scale, scale);
    // Paint image.
    Graphics2D g2d =
    outImage.createGraphics();
    g2d.drawImage(inImage, tx, null);
    g2d.dispose();
    // JPEG-encode the image
    //and write to file.
    OutputStream os =
    new FileOutputStream(thumb);
    JPEGImageEncoder encoder =
    JPEGCodec.createJPEGEncoder(os);
    encoder.encode(outImage);
    os.close();
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(0);
    I will be changing the following line right off the bat:
    1 ) changing the argument passed to:
    Image inImage = new ImageIcon(bytes);
    I'm passing it my array
    bytes
    which I created in my upload servlet, it's holding the image.
    I don't want to write the newly thumbnail sized image to a JPEG stream as it is coded at the end of the program from Sun.
    Instead, I want to read the newly sized image into a
    byte[ ]
    array and then continue with my servlet program, and place the image into the db. I have a column of type BLOB waiting for it:)
    Does anyone know how to do this?

    Yes I have done this, do not have the code to hand, its in a real mess anyway, one of those things I got working and never got round to using...
    I based my code on some found here
    http://forum.java.sun.com/thread.jspa?forumID=20&threadID=505366
    Note, the above link shows how to add a watermark to an image as well.
    It does not show how to resize it (I was originally after the watermark bit) But I got it to resize by messing with the variables used to draw out the image.
    If you search the forums you will find this a common problem, but I was very impressed with the code posted in the above link, one of my favorites!

  • Create image from byte[]array on server side

    Hello everyone..
    I'm developing an application which will take snapshots from a mobile device, and send it to my pc via bluetooth. I have my own midlet which uses the phone camera to take the snapshot, i want to transfer that snapshot to my pc.
    The snapshot is taken is stored in an array byte.
    The image can be created on the phone itself with no problem using : image.createImage(byte[])
    my problem is that when i send the array byte via bluetooth, and receive it on the server, i cannot create the image using the :image.createImage() code
    The connection is good since i have tested by writing the content of the array in a text file.
    Piece of midlet code:
                try{
                     stream = (StreamConnection)Connector.open(url);
                     OutputStream ggt = stream.openOutputStream();
                     ggt.write(str);
                     ggt.close();
                }catch(Exception e){
                     err1  = e.getMessage();
                }where str is my array byte containing the snapshot
    And on my server side:
    Thread th = new Thread(){
                   public void run(){
                        try{
                             while(true){
                                  byte[] b = new byte[in.read()];
                                  int x=0;
                                  System.out.println("reading");
                                  r = in.read(b,0,b.length);
                                  if (r!=0){
                                       System.out.println(r);     
                                       img = Image.createImage(b, 0, r);
                                                            //other codes
                                       i get this error message:
    Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: javax.microedition.lcdui.ImmutableImage.decodeImage([BII)V
         at javax.microedition.lcdui.ImmutableImage.decodeImage(Native Method)
         at javax.microedition.lcdui.ImmutableImage.<init>(Image.java:906)
         at javax.microedition.lcdui.Image.createImage(Image.java:367)
         at picserv2$1.run(picserv2.java:70)
    Please anyone can help me here? is this the way to create the image on the server side? thx a lot

    here is exactly how i did it :
    while(true){
                                  byte[] b = new byte[in.read()];
                                  System.out.println("reading");
                                  r = in.read(b, 0, b.length);
                                  if (r!=0){
                                       Toolkit toolkit = Toolkit.getDefaultToolkit();
                                       Image img = toolkit.createImage(b, 0, b.length);
                                       JLabel label = new JLabel(new ImageIcon(img) );
                                       BufferedImage bImage = new BufferedImage(img.getWidth(label),img.getHeight(label),BufferedImage.TYPE_INT_RGB);
                                       bImage.createGraphics().drawImage(img, 0,0,null);
                                       File xd = new File("D:/file.jpg");
                                       ImageIO.write(bImage, "jpg", xd);
                                       System.out.println("image sent");
                             }Edited by: jin_a on Mar 22, 2008 9:58 AM

  • Need to create a background image for Joomla

    I need to create a custom background image for a Joomla site.
    Can anyone offer a simple tutorial on the steps I need to take to create the image?
    Thanks

    Okay. The image has a gold gradient from top to bottom, but the text repeats in smaller blocks.
    First, you need a tiling image of some text, on a transparent background. Then, this image needs to be added as a pattern in Fireworks.
    Next, you get to use your new pattern. In your document, create a tall rectangle with a vertical gradient. Make this image the same width as your tiling pattern, so that your resulting background image will also tile. Over that you put a rectangle with no color fill, but fill it with the text pattern. Save this working Fireworks document, then export to use on the Web.
    I don't understand the phrase "I need to know how to size the image, possibly with CSS." Background images are the size they are. When this image is set to be the background, then it should be specified to repeat in the horizontal direction (repeat-x).
    Here's some info on making a seamless tile:
    http://forums.adobe.com/message/2384441
    Using patterns:
    http://www.entheosweb.com/fireworks/patterns.asp
    There have been some recent threads on using gradients, just flip back a page or two (unless my mind's playing tricks on me and they're older).
    Hmm... Possibly helpful:
    http://spectrum.troy.edu/~techtip/classes/tutorials/fireworks/fw2004/gradient/gradient.htm

  • Need to create mpeg4 simple profile 720X480

    Hi,
    I recently got a Sony head unit for my car. I see it has the capability of playing .mp4 video off of USB thumbdrives, but the settings for the videos are hard to achieve. I have tried After Effects, Adobe Media Encoder, Quicktime, and Handbrake, and couldn't get it. For After Effects, everytime I set it to an mp4 simple profile, it would down rez the aspect ratio. (the aspect ratio wouldn't get altered if it was the H264 mp4, but it needs to be simple profile). For Handbrake, I set the right settings, but upon playback in the car, the audio would trail off within the first minute.
    The exact specs I need are:
    • Profile: MPEG-4 Simple profile*
    • Bit rate: Max. 7 Mbps on USB FS, 10 Mbps on
    DVD, 7 Mbps on CD
    • Frame rate: Max. 30 fps
    • Image size: Max. 720 × 480 pixels
    • Audio: Max. 320 kbps (AAC-LC)
    • File extension: .mp4
    Can someone please help me out with this? I'm comfortable with the render que with After Effects, but I've never used Compressor before. My main goal is to be able to have the video at a decent bit rate to where it's completly clear and not pixelated / be able to skim through to half way through the movie and the audio is still entact and not off timing. Oh, and if a movie could be roughly around 1GB that would be an extra plus.
    Please help, thanks.

    Toast allows MPEG-1 export. It is the format of VCD's (CD's that play in DVD players).
    I have an export to Toast option in my QuickTime Pro dialogs that will export any of my QT file formats to .mpg
    You can also use it to create a VCD (no need to burn the disc) and drag the blah.DAT file out to the Desktop. Renaming the file to blah.mpg is all you need to do.

  • I need to create a ghost image of my G4 iBook (OSX 10.3.9) and replace the OS9 on my G4 tower with the created iBook ghost image. How do you do this?

    I need to create a ghost image of my G4 iBook (OSX 10.3.9) and replace OS9 on a G4 tower with the Ghost image. How do you do this? Will my applications still work?
    The iBook is running Pather, i have tons of programs i use on it, project files, etc... and my G4 Mac tower is more powerful, faster, and more reliable than the iBook. I basiclly just want to take the entire OS, programs and files... create an image, and drop the image on the G4 Tower so it basically will function just like the iBook. Like a mirror image of everything that is on the iBook.  I know that you can create image files in the Disk Utility on Panther, but will that back up the entire OS with settings, programs, files and all?  ive never done anything like this before, so i wanted to post this up to see if i would get an answer. In the meantime, im reading "Mac OS X, Help Desk Essentials By Owen Linzmayer" to see if i can find the steps to do this.
    Any help would be greatly apprciated. Much thanks!

    Can't be done as an exact copy from one Mac to the other.  The operating systems are system specific. First make sure your system doesn't need a firmware update to get 10.2 or later on it. You'll need to install 9 on it if it does, direct from a 9 retail CD that is compatible with it *.  This disc can't say Upgrade, Dropin, or OEM. To determine compatibility, identify your G4 tower:
    http://support.apple.com/kb/HT3082
    http://docs.info.apple.com/article.html?artnum=42739
    Then look at the OS 9 compatibility:
    http://docs.info.apple.com/article.html?artnum=25517
    Then apply the correct update
    http://docs.info.apple.com/article.html?artnum=86117
    The last Mac OS 9 to come retail is 9.2.1, and that's newer than 9.0.4, 9.0.2, and 9.1.
    Your ghost image can be done using cloning software, but then you'll have to use a retail 10.3 installer and 10.3.9 combo update on the G4 tower.  Then use the Migration Assistant to import the data from the clone of the iBook. The 10.3 retail disc looks like * and does not say upgrade, dropin, or OEM.  The 10.3.9 combo update is here:
    http://www.apple.com/support/downloads/macosxcombinedupdate1039.html
    The clone to an external hard drive can be done with these instructions*:
    http://www.macmaps.com/backup.html The import of the external hard drive with the migration assistant can be done with these instructions:
    http://docs.info.apple.com/article.html?artnum=25773

  • I need to create 4 A2 boards that print adjacent to one another with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards.Do I use illustrator (C3) or Indesign?

    I need to create 4 @ A2 boards that print adjacent to one another (all landscape format) with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards? Is it best to use Illustrator(CS3) or Indesign?
    Thanks.

    Re: I need to create 4 A2 boards that print adjacent to one another with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards.Do I use illustrator (C3) or Indesign
    If possible, please try Indesign CS 4.

  • Need to create/buy/Use a Web based Image Editor

    Hi all
    I'm new here, just got a new project for printing shop, they need to have their users editing Business cards to put their own information.
    So there will be a tamplet of cards and user can pick up up and edit it accordingly and save it to the server.
    I have looked many places but couldnt find a flash web based editing comp. if you have one or know of one please notify me, or if you can make one.
    Here is an example of what I am talking about
    http://67.18.244.218/startdemo.asp?tp=3
    click on any image to see what we need.
    Your help is much appreicated.
    Thanks in advance

    here is an example, again this is a brower based.
    You got a simple image with few layers and simple funcationality to change it, like changing the text, colors, positions ....

Maybe you are looking for

  • ITunes and Computer think my iPhone 3G is a new/different phone

    I Connected my iPhone to my computer to Sync it today and it went straight to the iTunes store and then showed a message saying "Congratulations you have actiavted your phone" or something similar. Now my iPhone which used ot have a personalised name

  • Outstanding Payment On Account balance on Incoming Payments

    Dear All, SAP 2005B PL:40 I would like to ask how to get the outstanding POA balance from Incoming Payments table (OCRT). Which database field can distinguish the completed POA and outstanding POA? Thank you in advance. Best Regards, Vivian

  • Poor video quality when exporting

    I am new to Premiere and don't know all the functions yet. (at all) I have wto questions. I have successfully imported and edited my video, but it seems, that the final result (the preview at the right) is cutting off the edges of my video. I have tr

  • XPathFactory error in embedded Java code

    Hi, I'm getting the following error when executing embedded Java code which does an XPath expression. Does anyone know why this is happening? Thanks. [2006/03/13 17:55:22] "{http://schemas.oracle.com/bpel/extension}bindingFault" has been thrown. less

  • Error mesages when attempting to connect laptop to WRT54GS v.4 router

    When I try to hook up my laptop (Dell Inspirion) to my network, the icon in the tray says it's connected.  When I try to open IE I get a won't connect message.  When I run network diagnostics, I get an error message (112029) stating that my proxy can