BGR bytes to Image

I have loads of data, in the form of a byte array in one long list of BGRBGRBGR values. There is a bufferedImage type BGR byte:
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
but how can i write my values into it? I tried getting a WritableRaster, but the arguments for that are int int int int[]
raster.setPixels(int startx, int starty, int width, int height, int[] pixels)
(which I havnt had any luck with iether, all my integer pixles are black..)
So far, Ive been trying to use int pixel values to just get something working:
public static Image getImageFromArray(int[] pixels, int width, int height) {
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        //image.
        int pix[] = new int[width*height*3];
        for (int i = 0 ; i < width*height ; i +=3){
             //pix=Color.BLUE.getRGB();
     pix[i]=255;
     pix[i+1]=0;
     pix[i+2]=0;
WritableRaster raster = (WritableRaster) image.getData();
raster.setPixels(0,0,width,height,pix);
return image;
}but its all black (oh, and i thought the int values contained the RBG (so i would use Color.BLUE>getRGB();) but the setPixels gets an arrayindex out of bounds for anything less than 3*width*height, suggesting its in int rgb format...
Edited by: IJustWantToSayHelloWorld on Aug 13, 2010 8:59 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

This method would wrap your byte[] array into a BufferedImage.
/**Wraps a BGRBGR... byte array into a TYPE_3BYTE_BGR BufferedImage*/
public static BufferedImage wrapInImage(byte[] imgData, int w, int h) {
    DataBuffer db = new DataBufferByte(imgData,w * h * 3);
    WritableRaster raster = WritableRaster.createInterleavedRaster(
            db,w,h,w*3, 3, new int[]{2,1,0}, null);
    ColorModel colorModel = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    new int[]{8,8,8}, false, false,
                    Transparency.OPAQUE,
                    DataBuffer.TYPE_BYTE);
    return new BufferedImage(colorModel, raster,false, null);
}Because you create the image from your own byte array, the image is guaranteed not be hardware accelerated. Graphical operations to or from the image may not be as fast as they can.
This method would create a new image (may be hardware accelerated), at the cost of memory and performance in creating the image.
/**Creates a new TYPE_3BYTE_BGR BufferedImage from a BGRBGR... byte array.*/
public static BufferedImage createImage(byte[] imgData, int w, int h) {
    DataBuffer db = new DataBufferByte(imgData,w * h * 3);
    WritableRaster srcRast = WritableRaster.createInterleavedRaster(
            db,w,h,w*3, 3, new int[]{2,1,0}, null);
    BufferedImage copy = new BufferedImage(w,h,BufferedImage.TYPE_3BYTE_BGR);
    //can be done several ways including row by row (which is not done here)
    copy.getRaster().setDataElements(0,0,srcRast);
    return copy;
}

Similar Messages

  • Depth data convert to Image Bgr, Byte in a windows store project

    Hi,
    i use EmguCv to process depth data from Kinect v2. Now i want to do it in a windows store 8.1 app. In older project i use these code to convert from writable bitmap:
    BitmapEncoder encoder = new BmpBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(depthBitmap));
    MemoryStream ms = new MemoryStream();
    encoder.Save(ms);
    Bitmap b = new Bitmap(ms);
    Image<Bgr, Byte> openCVImg = new Image<Bgr, Byte>(b);
    I the project i miss the bitmap class, i search the whole day for a solution...
    Thx for any hlp
    René

    The answer with help from Canming Huang (Thx):
    private Image<Bgr, Byte> Array2IImage(byte[] pixelArray)
    GCHandle dataHandle = GCHandle.Alloc(pixelArray, GCHandleType.Pinned);
    try
    using (Image<Bgra, Byte> image = new Image<Bgra, byte>(this.pixelWidth, this.pixelHeight, this.pixelWidth * this.cbytesPerPixel, dataHandle.AddrOfPinnedObject()))
    return image.Convert<Bgr, Byte>();
    finally
    dataHandle.Free();

  • Bytes to image at server

    Hi
    I am doing client server application which send image from client to server...
    i am able to send image bytes from client to server ..But at server I am not able to display image which i sent from client.............
    Can you guys plz tell how i can convert bytes to image at Servlet server.....
    Thanks in advance...

    DragEvent has property called dragInitiator. That might help.
    Otherwise, you can add mouseDown event listener to your
    TileList and in that handler do something like:
    var initiator:UIComponent = UIComponent(event.currentTarget);
    and then add any effects to the initiator.
    ATTA

  • Need to convert byte[] to image

    hi frnds,
    i have a byte[](which i got it from an image) i need to convert back to image.Could u pls suggest me how to??
    i tried with Pixelgrabber but i exaclty did get wht shld be the input for it(tried giving image file name). :(
    So pls let me know how and wht to use..ASAP.
    Regards
    subinjava

    Subinjava wrote:
    ..i have a byte[](which i got it from an image) i need to convert back to image.Could u pls suggest me how to??
    Image image = Toolkit.getDefaultToolkit().createImage(byteArray)See http://java.sun.com/javase/6/docs/api/java/awt/Toolkit.html#createImage(byte[]) for more details.

  • Displaying Byte Array images in coldfusion

    This has been driving me crazy for a couple of days now.I
    have a Java class that returns pictures stored in a DB as a Byte
    Array.
    I am able to display the image but that is all i am able to
    do - I want to display the image name, description etc in a HTML
    before i display the actual image but i can't seem to find a way to
    do that.
    I tried using CFcontent as well and that did not help
    either.This is what i am currently doing - and all that displays on
    the screen is the picture and all content before the picture is
    nowhere to be seen.
    Picture Name: #variables.picName#
    Picture Description:#variables.picDescription#
    <cfscript>
    context = getPageContext();
    response = context.getResponse().getResponse();
    out = response.getOutputStream();
    response.setContentType("image/jpeg");
    response.setContentLength(arrayLen(session.picture));
    out.write(session.picture);
    out.flush();
    out.close();
    </cfscript>
    Any help will be greatly appreciated.

    Mark,
    Note that the portal sets the content type (e.g, text/html) and encoding
    as the portal page starts rendering. In your case, the
    setContentType() would be useless since the servlet container won't let
    you change it. You can either use a popup browser window for the pdf as
    Kunal suggested, or use an iframe if you want to render the pdf inside
    the portlet window.
    Subbu
    Mark Gilleece wrote:
    Hi,
    i need to display a PDF file. The PDF is stored in a byte array. This works fine when i run my code (see below) from the .jpf via the debugger/browser, but when i use it as a portlet, in the portal, it does not work ?
    Any help is much appreciated.
    Thanks
    Mark
    byte[] pdfDocument = docStore.getPDF();
    ServletOutputStream outPdf = response.getOutputStream();
    response.setContentType("application/pdf");
    outPdf.write(pdfDocument);
    outPdf.flush();
    outPdf.close();

  • Display byte array image or ole object in Section through dynamic code?

    To Start I am a Complete Newbe to Crystal Reports. I have taken over a project originally written in VS2003 asp.net using SQL Server 2005 and older version of Crytal Reports. I have moved project to VS2010 and Cryatal Reports 10 still using SQL Server 2005. Have multiple reports (14 to be exact) that display data currently being pulled from database suing a dataset, each report has from 4 to 14 Sections. I have modified database table with two new fields. Field1 contains string data with full path to a scanned document (pdf or jpeg). Field2 holds a byte array of the actual image of the scanned document. I have tested the database and it does infact contain the byte array and can display the image via VB.net code. I can make the report display the scanned image using ole object.
    Now my real question: I need to add a new Section and it should display either the byte array of the scanned image or the actual scanned image (pdf or jpeg) . How can I have it do either of these options via code dynamicly while application is running?

    First; only CRVS2010 is supported on VS2010. You can download CRVS2010 from here;
    SAP Crystal Reports, developer version for Microsoft Visual Studio: Updates & Runtime Downloads
    Developer Help files are here:
    Report Application Server .NET API Guide http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/xi4_rassdk_net_api_en.zip
    Report Application Server .NET SDK Developer Guide http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/xi4_rassdk_net_dg_en.zip
    SAP Crystal Reports .NET API Guide http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet_api_2010_en.zip
    SAP Crystal Reports .NET SDK Developer Guide http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet_dg_2010_en.zip
    To add the images, you have a number of options re. how to. You even have two SDKs that y ou can use (RAS and CR).
    Perhaps the best place to start is with KB [1296803 - How to add an image to a report using the Crystal Reports .NET InProc RAS SDK|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233393336333833303333%7D.do]. The KB describes how to add images to a report using the InProc RAS SDK, but also references other KBs that use CR SDK.
    Also, don't forget to use the search box in the top right corner of this web page.
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Save byte array (image) to file with servlet

    Good day.
    I should must to save a png image to file.
    I have a byte array of the image.
    This work is in a servlet.
    How can I do it?
    Best regards.
    Stefano Errani

    Good day.
    I have a byte[] and then I have used
    FileOutputStream fos = new FileOutputStream(getServletContext().getRealPath("/public_html/mcfoto/foto1.png"));
    fos.write(bt, 0, bt.length); // byte[] bt
    fos.close();
    This on my web server that has public_html as root web directory.
    The server is in multi domain.
    In this mode I have an error.
    Then I have tryied to use
    FileOutputStream fos = new FileOutputStream("http://www.stefanoerrani.it/mcfoto/foto1.png");
    and
    FileOutputStream fos = new FileOutputStream(getServletContext().getRealPath("http://www.stefanoerrani.it/mcfoto/foto1.png"));
    In both ways I have obtained an error.
    At last I have tryied in my localhost (local machine) using
    FileOutputStream fos = new FileOutputStream(getServletContext().getRealPath("/mcfoto/foto1.png"));
    All run correclty.
    The Application Server is Tomcat with Apache HTTP Server.
    The first server (of www.stefanoerrani.it) has Linux as OS.
    My local server has Windows as OS.
    I should want, if it's possible, an help.
    Best regards.
    Stefano Errani

  • Not enough bytes in image stream

    Hi
    I'm developing a program that reads/modifies/saves PDF files. I found a strange imagestream in the PDFReference Document:
    2385 0 obj
    <</Length 255/Filter /FlateDecode/Width 155/Height 76/BitsPerComponent 8/ColorSpace 36619 0 R/Type /XObject/Subtype /Image>>
    stream
    [Binary Data]
    endstream
    endobj
    36619 0 obj
    [/Indexed /DeviceCMYK 153 2378 0 R]
    endobj
    2378 0 obj
    <</Length 264/Filter/FlateDecode>>
    stream
    [Binary Data]
    endstream
    endobj
    The decoded stream of object 2385 is 5080 bytes long.
    The decodes stream of object 2378 is 616 bytes long.
    Strange:
    Height/Width*BitsPerComponent = 76*155*8 = 94240 bits = 11780 bytes!
    The length of the stream is only 5080 bytes long.
    Aren´t there to less bytes for the image?
    Or did i misunderstand something?
    PDF viewers can display this PDF correctly, so there must be something I dont know...
    What is the secret?
    Thanks for your help!

    I've found the error now. It was my FlateDecode algorythm which had a too small buffer for some streams, which had a very good compression rate. So they were cut. There aren´t much streams which such a compression rate, so I didn´t realize this a long time.
    Thanks anyway!
    Have a good day!

  • Get bytes from image

    Hi,
    Can someone please tell me how to get the bytes from an Image object in an applet. I need to send the data to php or asp script to save to image file on server. Preferably in jpeg format if thats possible. Thanks.

    what i need is to save an Image object to the server. I have written all the applet functionality in editing the image in various ways i just need to know how to get all the data and transform to jpeg data that can be sent from applet to a php script that simply writes the data it recieves to the disk. so far all ive been able to do is get short things like [B@4e2f0a to be written to the file on server. can someone please direct me as to waht i need to do and show me working code example or something. thanks alot.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to get Byte[] from an image object?

    This are the codes that i have tried, it did an resized.jpg but the file doesnt consist of the image. My program will stream the .jpg file using fileconnection then i resize the image and created the new image using image.createRGBImage(). Lastly, i need to save the resized image as a jpeg file but i failed to do so..
    byte[] jpegData = ImageByteConverter.getByteArray(image);
    OutputStream out = fconn.openOutputStream();
    out.write(jpegData,0,jpegData.length);
    * This method converts a int-array, containing all RGB values for the image, to
    * a byte-array containing all RGB values.
    public static byte[] getByteArray(Image image){
    // Allocate new memory for the int-array and fill the array in the getRGB method.
    int[]raw = new int[image.getWidth() * image.getHeight()];
    image.getRGB(raw, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
    byte[]rawByte = new byte[image.getWidth() * image.getHeight() * 4];// ARGB
    int a, r, g, b;
    int n = 0;
    // loop through the int-array and get the 4 bytes of each value to the byte-array.
    // since java isn't supporting unsigned bytes we need to store the ARGB values from -128 to 127
    // where -128 = 128, -127 = 129 and -1 = 255
    for(int i=0; i<raw.length; i++){
    // Right-shift the values to fit in a byte.
    int ARGB = raw;
    a = (ARGB & 0xFF000000) >> 24;
    r = (ARGB & 0xFF0000) >> 16;
    g = (ARGB & 0xFF00) >> 8;
    b = (ARGB & 0xFF);
    rawByte[n] = (byte)b;
    rawByte[n+1] = (byte)g;
    rawByte[n+2] = (byte)r;
    rawByte[n+3] = (byte)a;
    n+=4;
    raw=null;
    return rawByte;
    Thanks in advance.

    you can do follwoing but not sure whether thats what you want.
    Also not sure whether its the best way.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(image, "PNG",baos);
    InputStream in = new ByteArrayInputStream(baos.toByteArray());

  • Problem with getting resized image's bytes

    I've got a problem with getting correct bytes of a newly resized image. The flow is that I retrive an image from the filesystem. Due to the fact that it is large I resize it to a 50x50px thumbnail. I can display this thumbnail in #benchmark1 (see code below). Unfortunately something's wrong with my imageToBytes funtion which returns reasonably small size of image but is totally useless - I can't make an image of it anymore so at #benchmark2 the application either crashes or keeps freezing. I saved this byte array on my disk and tried to preview under Windows how does it look but I got a message "Preview unavailabe". I did some digging in the Internet and I supposed that it's because I don't use any jpg or png encoders to save the file. Actually I think that it's not the case, as the bytes returned from method imageToBytes look weird - I cannot even make a new image of them and display it without any saving in memory.
                                  byte[] bytes = FileHandler.readFile (
                                          FileHandler.PHOTOS_PATH, fileName);
                                  Image img2 = Image.createImage (bytes, 0, bytes.length);
                                  img2 = ImageHandler.getInstance ().resize (img2);
                                                    //#benchmark1
                                  bytes = ImageUtils.imageToBytes (img2);
                                  img2 = Image.createImage (bytes, 0, bytes.length);
                                                    //#benchmark2my imageToBytes function is as follows:
         public static byte[] imageToBytes (Image img)
              int[] imgRgbData = new int[img.getWidth () * img.getHeight ()];
              byte[] imageData = null;
              try
                   img.getRGB (imgRgbData, 0, img.getWidth (), 0, 0, img.getWidth (),
                           img.getHeight ());
              catch (Exception e)
              ByteArrayOutputStream baos = new ByteArrayOutputStream ();
              DataOutputStream dos = new DataOutputStream (baos);
              try
                   for (int i = 0; i < imgRgbData.length; i++)
                        dos.writeInt (imgRgbData);
                   imageData = baos.toByteArray ();
                   baos.close ();
                   dos.close ();
              catch (Exception e)
              return imageData;
    I've run totally out of any idea what's wrong, please help!
    Edited by: crawlie on Jul 17, 2010 6:21 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hey Crawlie,
    Please note that simply writing int values into ByteArrayOutputStream will not suffice. Please have a look at the following conversion from int pixel value into byte[4]:
    public static final byte[] intToByteArray(int value) {
            return new byte[] {
                    (byte)(value >>> 24),
                    (byte)(value >>> 16),
                    (byte)(value >>> 8),
                    (byte)value
    }Good Luck!
    Daniel

  • Reading an image in byte form

    hii guys
    i m trying to read an image and convert it to byte array and later to do some change in that byte array and later recreate a new image.
    For that i m using FileInputStream and FileOutputStream and its read and write methods
    but now i dont know how to append that byte and recreate that image.
    actually i want to do that , convert the image in byte array form and replacing some bytes of the image by my text msg bytes and recreate a new image.
    how an i do that.
    plz help me.
    its urgent.

    import java.io.*;
    class image
    public static void main(String[] arg) throws IOException
    String msg;
    int len,i;
    FileInputStream fin;
    FileOutputStream fout;
    try
    try
    fin=new FileInputStream("01.jpg");
    catch( Exception e)
    System.out.println("Input image not found");
    return;
    try
    fout=new FileOutputStream("001.jpg");
    catch( Exception e)
    System.out.println("output image cannt be created");
    return;
    catch(Exception e)
    System.out.println("output image cannt be created");
    return;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the secret msg :: ");
    msg=br.readLine();
    byte[] msg1=msg.getBytes();
    len=msg1.length;
    System.out.println(len);
    for(i=0;i<len;i++)
    System.out.println(msg1);
    try
    do
    byte by=(byte)fin.read();
    //System.out.print(" "+by);
    if(fin.available()>0)
    fout.write(by);
    }while(fin.available()>0);
    catch(Exception e)
    System.out.println("File error");
    fin.close();
    fout.close();
    till now i only imputed the sg , change it into byte form .
    now i want to replace the msg bytes into the image byte as :- 1 image byte ,1 msg byte, 1 image byte , 1 msg byte........ so on
    until the msg bytes are not finished.

  • How to convert a Image object to byte Array?

    Who can tell me, how to convert Image object to byte Array?
    Example:
    public byte[] convertImage(Image img) {
    byte[] b = new byte...........
    return b;

    Hello,
    any way would suit me, I just need a way to convert Image or BufferedImage to a byte[], so that I can save them. Actually I need to save both jpg and gif files without using any 3rd party classes. Please help me out.
    thanx and best wishes

  • Problem in saving the image into SQL database..

    Hello,
    In my application I have to save image file (say jpg) into the database and retrieve back and display it on the applet. I am through with grabbing the pixels of the image & sending the pixel array to the servlet but I am struck in how to store the image into the database and retrieve the same.
    Can anybody please help me in this regard... its really urgent...
    Thanks in advance
    Swarna

    Hello.
    I've been researching this problem (saving images in a MySQL database) in order to accomplish a task I was assigned to. Finally I was able to do it. I'd be glad if it will be of any use.
    First of all: the original question was related to an applet. So, the post from rkippen should be read. It says almost everything, leaving the code job for us. Since I managed to write some code, I'll put it here, but I'm not dealing with the byte transferring issue.
    To obtain a byte array from a file I'd open the file with FileInputStream and use a loop to read bytes from it and save them into a ByteArrayOutputStream object. The ByteArrayOutputStream class has a method named �toByteArray()� which returns an array of bytes (byte [] b = baos.toByteArray()) that can be transferred in a socket connection, as said by rkippen.
    My problem was to save an image captured by a web camera. I had an Image object, which I converted into a byte array and saved into the database. Eventually I had to read the image and show it to the user.
    The table in the MySQL database could be:
    CREATE TABLE  test (
      id int(11) NOT NULL auto_increment,
      img blob NOT NULL,
      PRIMARY KEY  (id)
    )I had problems trying to use the �setBlob� and �getBlob� methods in the Statement object, so I used the �setBytes� and �getBytes� methods . In the end, I liked these methods most because they where more suitable to my application.
    The database operations are:
        public int insertImage(Image image) throws SQLException {
            int id = -1;
            String sql = "insert into test (img) values (?)\n";
            PreparedStatement ps = this.getStatement(sql);  // this method is trivial
            byte [] bytes = this.getBytes(imagem); // * see below
            ps.setBytes(1, bytes);
            ps.executeUpdate();
            id = ps.getGeneratedKeys().getInt(0); //Actually I couldn't make this line work yet.
            return id;
        public Image selectImage(int id) throws SQLException {
            Image img = null;
            String sql = "select img from test where id = ?\n";
            PreparedStatement ps = getStatement(sql);
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                byte [] bytes = rs.getBytes(1);
                img = this.getImage(bytes); // * see below
            return img;
        }* If the bytes are read directly from a file, I think it is not necessary to convert it into an Image. Just send the bytes to the database method would work. On the other hand, if the image read form the DB will be written directly into files, the bytes obtained from rs.getBytes(1) would be enough.
    The image operations are:
        public byte [] getBytes(Image image) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ImageIO.write(this.getBufferedImage(image), "JPEG", baos);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return baos.toByteArray();
        public Image getImage(byte [] bytes)  {
            Image image = null;
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            try {
                image = ImageIO.read(bais);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return image;
        public BufferedImage getBufferedImage(Image image) {
            int width = image.getWidth(null);
            int height = image.getHeight(null);
            BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2d = bi.createGraphics();
            g2d.drawImage(image, 0, 0, null);
            return bi;
        }That's it. I hope it is useful.

  • 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

Maybe you are looking for

  • How do I download videos in different formats from an external hard drive?

    How do I download videos in MPEG and other formats from an external hard drive to  a MacBook?

  • Java Proxy- Exchange Profile Parameters

    Hi all, Do we have to set any exchange profile paramters for the java runtime to function to transfer the data from the messaging system to java proxy method. Pleas let me know if we need to set any such parameters. Thanks and Regards Arvind

  • Complex workflow  for  confirmation

    Hi All, We are running on SRM 5.0....We are implementing the Classic Scenario.....wherein once the SC is created in SRM ..the follow on docs...starting with Pur Req...are created in the Backend. Also in the confirmation process,i need to do a two lev

  • Transparent background for embedded swfs (not html)

    i'm bringing external swfs into my main movie and would love for the content of these to be visable without haveing a flat colour background. is this possible? thanks.

  • Two silly questions that need an answer

    Thanks in advance. IMAC - INTEL CORE DUO - CPU SPEED 2ghz 1) When I drag something into the trash, it asks 'The item ______ will be deleted immediately. Are you sure you want to continue? Where is the setting in the finder that just places it in the