Output Image using OutputStream

All
There's a need to display a graph created by jFreeChart:
ChartUtilities.writeChartAsPNG(out, chart, width, height)It should display in a new window after pressing a Plot-Button in the application window.
How would one do this?
Basically I need to set the content type to 'image/png' and then I need a OutputStream which I can write to.
Where to begin? Is this possible at all? Alternatively one could put the graph to a file and then use that ;-(
Thanks a lot for any help

Well, not many suggestions eh?
I did this one (based on another post in the forum).
Just for those interested ;-)
    public String getPlotUrl() {
        log.debug("Creating a temporary Graph-File");
        ServletContext context = ( ServletContext ) getExternalContext().getContext();
        String realPath = context.getRealPath("/resources");
        File file = null;
        try {
            file = File.createTempFile( this.getHttpSession().getId(), ".png", new File( realPath ) );
        } catch (IOException e1) {
            e1.printStackTrace();
        file.deleteOnExit(  );
        OutputStream outs = null;
        try {
            outs = new BufferedOutputStream( new FileOutputStream( file ) );
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        ChartGenerator cg = new ChartGenerator(this.getRequestBean());
        cg.createChart();
        try {
            cg.printChart( outs );
        } catch (IOException e) {
            e.printStackTrace();
        try {
            outs.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        setPlotUrl( "/resources/" + file.getName());
        log.debug("Temp. File: " + this.plotUrl);
        return this.plotUrl;
    }

Similar Messages

  • Problem to output image using ServletOutputStream

    Hallo everybody! Can anybody help me? I try to output image (jpeg) using ServletOutputStream. First I upload jpeg image to server disassemble it to binary data and save to database binary data, image length, and image type. Then I try to output image.
    Here the code:
    response.reset();
    response.setContentType(strContentType);
    ServletOutputStream sos=response.getOutputStream();
    sos.write(buf,0,bflen);
    sos.close();
    variable buf is array of byte with binary data
    bflen is image length
    strContentType it image type (image/pjpeg)
    I use JRun server 3.1
    I tried to save an image file:
    FileOutputStream fos = new FileOutputStream("test_logo.jpg");
    fos.write(buf,0,bflen);
    fos.close();
    And I got an jpeg file.

    I've done the exact same thing... almost. I have a
    servlet that sends a jpeg file to an applet for
    processing. Anyway, I did two things differently.
    First I used the write(byte[]) rather than
    write(byte[], int offset, int length). If you're
    going to send the whole array anyway, don't bother
    with the other parameters.
    Second, I call flush() on the output stream before I
    close it. I have a feeling this is why. Remember,
    web connections are connectionless. You don't know if
    the data was send or received. I assume what is
    happening is that you try to send the data then close
    the connection right away and the data may not get to
    the destination.
    Here's what I have. I don't think the content type
    really matters but I know multipart/form-data is
    binary.
    response.setContentType("multipart/form-data");
    response.getOutputStream().write(image.data);
    response.getOutputStream().flush();
    response.getOutputStream().close();
    I'll try it. But I have problem to call getOutputStream() method. It produce IllegalStateExeption. I think that because implicit getWriter() method calls. (I use JSP)
    Do you know how to reset somehow response to have ability to call getOutputStream()?

  • Print Images using FOP

    Can we print images using FOP by taking it from the database ? Iam using the FOP and outputing to a PDF. However, I have an image that I would like to print. The image is stored in the database as a BLOB. How can I print this image in the PDF document ?
    (b) Alternatively, if this is not possible, do we need to move the image to a physical file system and use <img src> and print ? If so, how can we move the image to the file system ? I found only UTL_FILE can do this ? But Iam not sure if it can work properly for Image file. When I tested this using utl_file, my image file got corrupted.

    Hi there, from what type of device are you trying to print the images from e.g. a smartphone/tablet or a PC/laptop?
    Best
    If my reply helped you, feel free to click on the Kudos button (hover over the "thumbs up").
    If my reply solved your problem please click on the Accepted Solution button so other Forum users may benefit from viewing the post.
    I am an HP employee.

  • Images used in FrameMaker files

    Since all of the images used in my documents are located in an image directory in the folder with my FrameMaker documents, I would like a way to run a report to list the file names that are associated with a book, file, or main directory. This would help me to remove images that are no longer needed to support my projects.
    I am using FrameMaker 8 on a Win XP SP2 operating system.

    I've used Add > List of > References (and then Imported Graphics) to get this sort of information for a book; if you throw some tabs in on the reference page, you can then paste the results to a spreadsheet or an editor and sort as required. If you feel like having a strange sort of fun, you can even use that output as the basis for a .bat file and move/delete all the redundant files in one go <g>

  • Problem grabbing image using libdc on ubuntu 12.10,build on new firewire-stack unibrain fire-i camera

    i am new to digital camera softwares.i am using unibrain fire-i camera on ubuntu 12.10 .firewire stack is new,i am using libdc1394 for grabbing images.i try to execute the example program grab-gray-image.the output image file is not giving result what i expected . i try to grab a human face image.i am adding this as an attachment. the camera parameters are as follows.
    Brightness:
    RC MC (active is: AUTO) AC (active is: AUTO)
    min: 128 max 383
    current value is: 304
    Exposure:
    RC MC (active is: AUTO) AC (active is: AUTO)
    min: 0 max 511
    current value is: 511
    Sharpness:
    RC MC (active is: MAN)
    min: 0 max 255
    current value is: 80
    White Balance:
    RC MC (active is: AUTO) AC (active is: AUTO)
    min: 0 max 255
    B/U value: 95 R/V value: 87
    Hue:
    NOT AVAILABLE
    Saturation:
    RC MC (active is: MAN)
    min: 0 max 255
    current value is: 90
    Gamma:
    RC MC (active is: MAN)
    min: 0 max 1
    current value is: 1
    Shutter:
    RC MC (active is: MAN)
    min: 0 max 7
    current value is: 6
    Gain:
    RC MC (active is: MAN)
    min: 0 max 255
    current value is: 87
    Iris:
    NOT AVAILABLE
    Focus:
    NOT AVAILABLE
    Temperature:
    NOT AVAILABLE
    Trigger:
    NOT AVAILABLE
    Trigger Delay:
    NOT AVAILABLE
    White Shading:
    NOT AVAILABLE
    Frame Rate:
    NOT AVAILABLE
    Zoom:
    NOT AVAILABLE
    Pan:
    NOT AVAILABLE
    Tilt:
    NOT AVAILABLE
    Optical Filter:
    NOT AVAILABLE
    Capture Size:
    NOT AVAILABLE
    Capture Quality:
    NOT AVAILABLE
    i am unable to identify the problem .please anyone help me.
    Thanks in advance.

    Excellent Blog. Thank You
    Small clarification on Step **6) Oracle Home Directory, ...a) Resize the Root Partition**
    Ubuntu 11.10 has Gparted available as a Ubuntu software download, DONT use that while trying the above step, instead download the ISO file from http://sourceforge.net/projects/gparted/files/gparted-live-stable/ gparted-live-0.12.0-5.iso (124.6 MB)
    Burn that ISO file on a Blank DVD, reboot the Ubuntu , during startup select Boot from DVD Option if not already selected. this will take to Boot Menu Options of Gparted Live then select the first menu option, and this allows to do further action such as Re-sizing .
    and once you have chosen and executed step a) . do NOT run step b) also that is "Setup External Storage"
    I hope this minor clarification can avoid some confusion
    Regards
    Madhusudhan Rao
    Edited by: MadhusudhanRao on Mar 24, 2012 11:30 PM

  • How to upload image using JSP

    hi,
    i am confronting a problem how to upload image from local PC to web server . I am using Tomcat 4.0
    please help me by sending code
    thanks

    Hi,
    Here is the solution for uploading images and displaying images. I am using struts with JSP, so this code has a Action and ActionForm class. You can put the same code in Java Beans or Servlet class to run it. This code has two JSP files - one for Upload (upload.jsp)and other for Image(image.jsp) display. It has a Servlet also to display the image. Here is the code file wise.
    Upload.jsp **********************************************************
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html>
    <head>
    <title>New Page 1</title>
    </head>
    <body>
    <html:form action="uploadAction.do" enctype="multipart/form-data" method="POST">
    <p>File to upload   
    <html:file property="fileUpload" size="20"/></p>
    <p><html:submit value="Upload" property="upload"/></p>
    <p> </p>
    <p><html:img src="image.jsp"/></p>
    <p> </p>
    </html:form>
    </body>
    </html:html>
    Image.jsp*****************************************************************
    <jsp:useBean id="upload" class="uploadtest.uploadActionForm" scope="session">
    </jsp:useBean>
    <%
         byte[] rgb=(byte[])session.getAttribute("byte");
         request.setAttribute("byArr", rgb);
    %>
    <!--
    The image data is now on the request object.
    Forward the user to the showImage servlet.
    That servlet will process and display the image data contained on the request object.
    -->
    Image is<p>
    <jsp:forward page="/showimage" />
    Struts Action Class - UploadAction.java **************************************************
    import javax.servlet.http.*;
    import java.io.*;
    import org.apache.struts.upload.FormFile;
    import org.apache.struts.action.*;
    public class uploadAction extends Action {
    public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
    uploadActionForm upload = (uploadActionForm) actionForm;
    try {
    int size=upload.getFileUpload().getFileSize();
    //if (image != null) {
    byte[] byteArr = new byte[size];
    //Create an input stream to read the uploaded file.
    ByteArrayInputStream bytein = new ByteArrayInputStream(upload.getFileUpload().getFileData());
    // Load the input stream into the byte Array.
    bytein.read(byteArr);
    // Close the input stream.
    bytein.close();
    // Load the byte[] into the content field.
    upload.setContent(byteArr);
    HttpSession ses=httpServletRequest.getSession();
    ses.setAttribute("byte",byteArr);
    return actionMapping.findForward("success");
    } catch (Exception ex) {
    ex.printStackTrace();
    return actionMapping.findForward("success");
    Struts ActionForm class ---uploadActionForm.java***************************************************
    package uploadtest;
    import org.apache.struts.action.*;
    import org.apache.struts.upload.*;
    import javax.servlet.http.*;
    public class uploadActionForm extends ActionForm {
    private FormFile fileUpload;
    private byte[] content;
    public FormFile getFileUpload() {
    return fileUpload;
    public void setFileUpload(FormFile fileUpload) {
    this.fileUpload = fileUpload;
    public byte[] getContent()
    return content;
    public void setContent(byte[] theFile)
    this.content = theFile;
    public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
    /**@todo: finish this method, this is just the skeleton.*/
    return null;
    public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
    Servlet to display image --- ShowImage.java ********************************************************
    import java.io.*;
    import java.util.*;
    public class ShowImage extends HttpServlet {
    //Initialize global variables
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    byte[] rgb = (byte[]) request.getAttribute("byArr");
    if (rgb != null)
    response.setContentType("image/gif");
    OutputStream stream = response.getOutputStream();
    stream.write(rgb);
    else
    response.setContentType("text");
    response.getWriter().write("attribute byArr not found");
    This code will enable to to upload and display the image. If you know Struts, then you can write the Struts-Config.xml file by yourself. Other wise write to me, I will send you that. If you want to save the image in database, then you have to keep it as BLOB datatype is database. For database you need to send the byte array in the uploadAction.java file to database. Database will keep the image as binary.
    Thanks
    Amit

  • Resizing Images Using LR3

    Specify Image Export Sizing. Question.
    The Adobe LR3 Help section says in th Specify image export sizing page:
    When exporting using the dimension option that the horizontal and vertical dimensions can be changed IRRESPECTIVE of the original values or aspect ratio. i.e. Like using the resizing option in PSE so an image can be tweaked to fit to better fit a frame..
    I have completely failed to make this work. My output image always appear to have the original aspect ratio.  Please can someone help?   Thanks lots Fred

    From help:
    Dimensions: Applies the higher value to the longer edge of the photo and the lower value to the shorter edge regardless of the photo’s original aspect ratio. Specifying 400 x 600, for example, produces a 400 x 600 portrait photo or a 600 x 400 landscape photo.
    I think you misunderstood that a bit.
    It won't change aspect ratio of the original. It's sort of like the first option — "width and height" — that automatically "rotates" depending on photo's orientation (landscape or portrait).

  • HELP!!!!Display blob image using JSP

    Hi,
    I am trying to blob image using JSP but it did not display successfully.
    Can someone help, please?
    below are the codes snippet:
    <td>
    <img src="display_image.jsp?ID=<%=request.getParameter("ID") %>" width="115" border="0">
    </td>
    byte[] image_blob = details.getImageByteArray();
    response.setContentType("image/jpeg");
    //response.setContentType("image/gif");
    //BEGINNING OF SECTION TO DISPLAY IMAGE
    /*OutputStream fos = null;
    fos = response.getOutputStream();
    fos.write(image_blob, 0, image_blob.length);
    fos.flush();
    fos.close();*/
    java.io.FileOutputStream fos1 = new java.io.FileOutputStream("C:\\"+id+".jpg");
    fos1.write(image_blob);
    fos1.close();
    OutputStream o = response.getOutputStream();
    System.out.println("o");
    o.write(image_blob);
    System.out.println(image_blob);
    System.out.println("write image");

    Use Java Image or BufferedImage instead of obscure byte array for image data.
    Here's an example code for a JSP document:
    <%
    String wid = request.getParameter("percent");
    String cost = request.getParameter("suchi");
    response.reset(); //IMPORTANT !
    response.setContentType("image/jpeg");
    // for testing purpose
    if (wid == null) wid = "58";
    if (cost == null) cost = "3400";
    float dleng = Float.parseFloat(wid) * 2.6f;
    RenderedImage rimg = drawGraph(dleng);
    OutputStream os = response.getOutputStream();
    try{
      ImageIO.write(rimg, "jpg", os);
    catch(IOException e){
    os.flush();
    %>
    <%!
    public RenderedImage drawGraph(float barLength){
      final int w = 800;
      final int h = 18;
      final int x = 0;
      final int y = 0;
      BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
      Graphics2D g2 = img.createGraphics();
      Color c = new Color(Integer.parseInt("FF9999", 16));
      g2.setColor(Color.yellow);
      g2.fillRect(x, y, w, h);
      g2.setColor(c);
      g2.fillRect(x, y, (int)barLength, h);
      g2.dispose();
      return img;
    %>

  • I am trying to softproof an image using a CMYK .icc file. I sent an image from LR 5 to PS CC 2014, opened the Camera Raw FIlter, but the hyperlink to access workflow is not showing up in the CR dialogue box... Any ideas why this might be?

    I am trying to softproof an image using a CMYK .icc file. I sent an image from LR 5 to PS CC 2014, opened the Camera Raw FIlter, but the hyperlink to access workflow is not showing up in the CR dialogue box... Any ideas why this might be?

    I am trying to softproof an image using a CMYK .icc file. I sent an image from LR 5 to PS CC 2014, opened the Camera Raw FIlter, but the hyperlink to access workflow is not showing up in the CR dialogue box... Any ideas why this might be?

  • Capture an image using the web camera from a web application

    Hi All,
    Could anyone please share the steps what have to be followed for capture an image using the web camera from a web application.
    I have a similar requirement like this,
    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.
    3) Upload the Image to the server from the temporary location.
    Please share the details like, what can be used and how it can be used etc...
    Thanks,
    Suman

    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)There's not really any good way to do this with JMF. You'd have to somehow create a JMF web-start application that will install the native JMF binaries, and then kick off the capture device scanning code from the application, and then scan through the list of devices found to get the MediaLocator of the web cam.
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.You'd probably be displaying a "preview" window and then you'd just want to capture the image. There are a handful of ways you could capture the image, but it really depends on your situation.
    3) Upload the Image to the server from the temporary location.You can find out how to do this on google.
    All things told, this application is probably more suited to be a FMJ (Freedom for Media in Java) application than a JMF application. JMF relies on native code to capture from the web cams, whereas FMJ does not.
    Alternately, you might want to look into Adobe Flex for this particular application.

  • Downloading images used to go automatically to the last folder used to save images, even when reopening Firefox. In just the past few days, possibly coinciding wih the most recent updates, the folder defaults to the 'Downloads' folder. This is most annoyi

    Downloading images used to go automatically to the last folder used to save images, even when reopening Firefox. In just the past few days, possibly coinciding wih the most recent updates, the folder defaults to the 'Downloads' folder. This is most annoying. What happened? Internet Explorer 8.0 did the same thing. This was one of the reasons why I started using Firefox to download all images. I went into Tools>Options and it only lets me set another folder. I dont want to set a specific folder I want it to always go to the last folder used. So what gives?
    == This happened ==
    Every time Firefox opened
    == possibly when the most recent updates were installed, a few days ago

    Thanks jscher 2000. I guess I didn't make it clear. "It restarts with all the addons activated, and resumes with the tabs that were open before closing it." IE, it's running fine now with all the extensions activated. Everything is OK now.
    So something in the Firefox code was causing the bad behavior. It's not essential that I find out what the problem was - I'm just curious. And if anybody else has this same problem, it might be nice to have it corrected at the source.

  • Create a new Buffered Image using Raster and ColorModel

    Sorry , I crosspost this message,because no one reply.
    Recently,I write a programme combining C++ and Java .
    The C++ part create a array containing image data in form of BI_RGB and biBitCount==32.
    The java part create a image using Raster and ColorModel like this:
       static int[] data ;
       DataBuffer db = new DataBufferInt(data, data.length);
       WritableRaster wr =Raster.createPackedRaster(db, 1024,768, 32, null);
       ColorModel cm = new DirectColorModel(32,0xff0000,0x00ff00,0x0000ff);
       img = new BufferedImage(cm, wr, false, null);But it doesn't work .
    it report this:
    Exception in thread "main" java.lang.IllegalArgumentException: Raster sun.awt.im
    age.SunWritableRaster@dff3a2 is incompatible with ColorModel DirectColorModel: r
    mask=ff0000 gmask=ff00 bmask=ff amask=0
    at java.awt.image.BufferedImage.<init>(BufferedImage.java:549)
    at monitor.test.Perform2.main(Perform2.java:39)

    hey epico
    compiles & runs 4 me
    see javadocs for SinglePixelPackedSampleModel
    import java.awt.image.*;
    public class Tester {
    DataBuffer db;
    WritableRaster wr;
    ColorModel cm;
    BufferedImage im;
    int[] data;
    int[] masks;
    int w = 768;
    int h = 576;
      public Tester() {
        data = new int[768*576];
        for (int i = 0;i < w*h ;i++ ) {
          data[i] = 0;
        masks = new int[3];
        masks[0] = 0xff0000;
        masks[1] = 0x00ff00;
        masks[2] = 0x0000ff;
        db = new DataBufferInt(data,data.length);
        SinglePixelPackedSampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,w,h,masks);
        cm = new DirectColorModel(32,0xff0000,0x00ff00,0x0000ff);
        wr = Raster.createWritableRaster(sm,db,null);
        im = new BufferedImage(cm,wr,false,null);
      public static void main(String[] args) {
        Tester tester1 = new Tester();
    }

  • Help displaying an image using the canvas!!!!!!!!

    Hey guys
    I don't know whether I am not grasping some concepts well.I have been going mad trying to get the code working
    Here is the code
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.*;
    * @author Administrator
    * @version
    public class MyMIDlet extends javax.microedition.midlet.MIDlet implements CommandListener{
    private Display display;
    private MyCanvas canvas;
    private Command exitcommand = new Command("Exit",Command.SCREEN,1);
    private Image source;
    public MyMIDlet() {
    protected void startApp() throws MIDletStateChangeException{
    if (display == null){
    initMIDlet();
    protected void pauseApp() {
    protected void destroyApp(boolean unconditional)throws MIDletStateChangeException {
    exitMIDlet();
    public void commandAction(Command c, Displayable d) {
    if (c == exitcommand){
    exitMIDlet();
    protected void initMIDlet() {
    display = Display.getDisplay(this);
    canvas = new MyCanvas(this);
    System.err.println("Canvas instiated succesfully");
    canvas.addCommand(exitcommand);
    canvas.setCommandListener(this);
    display.setCurrent(canvas);
    public void exitMIDlet() {
    notifyDestroyed();
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import java.io.*;
    public class MyCanvas extends Canvas implements Runnable {
    private MIDlet midlet;
    private Image offscreen;
    private Image currentimage;
    private Graphics g;
    //MID profile application
    /** Creates a new instance of MyCanvas */
    public MyCanvas(MIDlet midlet) {
    this.midlet = midlet;
    try{
    currentimage = Image.createImage("/bird0.png");
    }catch(IOException e){
    System.err.println(e.getMessage());
    if (currentimage!= null){
    System.err.println("Image create successfully");
    }else{
    System.err.println("Image not created");
    try{
    Thread t = new Thread(this);
    t.start();
    }catch(Execption e){}
    protected void paint(Graphics g){
    Graphics saved = g;
    int x = getWidth();
    int y = getHeight();
    g.setColor(255,255,255);
    g.drawImage(currentimage,x,y,g.TOP|g.VCENTER);
    public void run() {
    repaint();
    I know for a fact that the Canvas class 's paint method is called by the system and not the application. This poses a problem for me because I am not sure how to pass the image to the piant method, so that it can be painted.
    When I run the program(using J2ME wtk04), this is the outcome.
    Image created succesfully
    Canvas instiatiated successfully
    null
    Here are my questions
    1) when is the paint method precisely called by the system?after a reference to the canvas class is created?
    2) is it wise to create the image when instiating the canvas class?( initially created the image using a separate thread)-when sould the image be created?
    3)how to let the application know when to use the image when painting the display area?
    I am just trying the logistics here. It is very crucial to me to understand the bolts of this as the core f my project fouses on the man machine interface development.(For the project, the cilent application is quering for the map using HTTP)
    I use a png file of size 161 bytes. Is that too big for testing purposes.
    I would all the help that I can get. thanks in advance

    1) when is the paint method precisely called by the system?after a reference to the canvas class is created?
    After the canvas is set as the current display, and after that, after the repaint() is called.
    2) is it wise to create the image when instiating the canvas class?( initially created the image using a separate thread)-when sould the image be created?
    It's better to create the image in the very begining of the program e.g. in the midlet initialization. You can call the created image as often as you like later on
    3)how to let the application know when to use the image when painting the display area?
    you have to tell it :))
    you can use if-then, switch, or anything else
    and you can use clipping too

  • Problem in creating 1 image using differnt images

    Dear Fellows I want to create an image by using different images in byte array format. Images may be transparent or normal images. I want final result in byte array. I am using the following technique which is working fine but the problem with this technique is that it takes too much time to create an image. This is because I am using MediaTraker. If I delete the code of MediaTracker then program have undeterministic behavior i.e, sometimes it create the final image properly and sometimes nothing is displayed in final image.
    I need some help from you. If anyone of you know the technique to draw image using different images without using mediaTracker kindly let me know.
    Early replies will be appreciated
    // here is the sample code which i m using for creating image
    byte[] backgroundImage= // read 800 X 600 image from disk and convert it in to byte array
    byte[] image1 = // read 200 X 200 image from disk and convert it in to byte array
    byte[] transparentImage // read 300 X 300 transparent image from disk and convert it in to byte array
    Image img=null;
    Frame frame =new Frame();
    frame.addNotify();
    //creating BufferedImage object to store Final image
    BufferedImage requiredImage= new BufferedImage(800,600,BufferedImage.SCALE_SMOOTH);
    //get Graphics of BufferedImage created above
    Graphics2D g=(Graphics2D) requiredImage.getGraphics();
    ///// begin draw back ground image
    img=Toolkit.getDefaultToolkit().createImage(backgroundImage);
    try
    MediaTracker mt = new MediaTracker(frame);
    mt.addImage(img, 0); // adds image with ID 0
    mt.waitForID(0);
    }catch(Exception myex)
    myex.printStackTrace();
    //draw background starting from x=0, y=0 with 800 X 600 dimentions
    g.drawImage(img,0,0,800,600,null);
    ////////// end draw background image
    ////////// begin draw image1
    img=Toolkit.getDefaultToolkit().createImage(image1);
    try
    MediaTracker mt = new MediaTracker(frame);
    mt.addImage(img, 0); // adds image with ID 0
    mt.waitForID(0);
    }catch(Exception myex)
    myex.printStackTrace();
    //draw image1 starting from x=10, y=10 with 200 X 200 dimentions
    g.drawImage(img,10,10,200,200,null);
    //////////// end draw image1
    //////begin transparentImage
    img=Toolkit.getDefaultToolkit().createImage(backData);
    try
    MediaTracker mt = new MediaTracker(frame);
    mt.addImage(img, 0); // adds image with ID 0
    mt.waitForID(0);
    }catch(Exception myex)
    myex.printStackTrace();
    //draw transparentImage starting from x=400, y=0 with 300 X 300 dimentions
    g.drawImage(img,400,0,300,300,null);
    ///end draw transparent image
    byte []finalResult = //convert requiredImage into byte array;
    you can mail me the solution on my email address [email protected]
    thanks with best regards
    and waiting for someone to reply
    kamran zameer

    is there anyone on this forum to help me??????
    regards,
    kamran zameer

  • Problem in creating client side PDF with image using flex and AlivePD

    I need a favor I am creating client side PDF with image using flex and AlivePDF for a web based application. Images have been generated on that pdf but it is creating problem for large size images as half of the image disappeared from that pdf.I am taking the image inside a canvas . How do i control my images so that they come fit on that pdf file for any image size that i take.
    Thanks in advance
    Atishay

    I am having a similar and more serious problem. It takes a
    long time to execute, but even attaching a small image balloons the
    pdf to 6MB plus. After a few images it gets up to 20MB. These are
    100k jpeg files being attached. The resulting PDF is too large to
    email or process effectively. Does anyone know how to reduce
    size/processing?

Maybe you are looking for