Rotating Images with Java 2D

Im working on a program that requires the use of rotating images. I am using AffineTransformation to rotate and translate my BufferedImages. I have a problem when I rotate, I have a picture posted bellow of sample code and it's output.
http://i125.photobucket.com/albums/p64/roryfenrir/tankhelp.png
I four images, back (a solid color background, will not be solid in final product); tread and base, both get rotated together; and top, which rotates seperatly from the others.
My problem is that when an image is rotated, it takes a section of the background with it even though its a seperate image. Im wondering how to fix or get around this problem. Sorry if this is a dumb question but I would really like to get this down.
Thanks.
Edited by: RoryFenrir on Nov 11, 2008 4:13 PM

alright sorry, I didnt think that I needed to paste the whole code. Anyway I tried it out on some other computers and it didnt have this problem, both computers I used had java 6.0 and mine has 5.0 (Im pretty sure) so maybe thats the problem, but anyway I would still like to figure it out for this computer.
heres the code for the paintPanel, the program that runs it just adds it as a panel then sends arguments into the Overpaint method.
import java.awt.image.BufferedImage;
import javax.swing.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.*;
public class TankPaint extends JPanel
  static BufferedImage back;
  private BufferedImage top,base,tread;
  private Graphics g;
  private int x,y,x2,y2,deg1,deg2;
  //boolean dialog = false;
     public TankPaint(String back,String top,String base,String tread,int deg1,int deg2,int x,int y,int x2,int y2)
          super();
          try
               this.back = ImageIO.read(new File("Backgrounds\\"+back));
               this.top = ImageIO.read(new File("Images\\"+top));
               this.base = ImageIO.read(new File("Images\\"+base));
               this.tread = ImageIO.read(new File("Images\\"+tread));
          catch (IOException ex) {}
          this.x = x;
          this.y = y;
          this.x2 = x2;
          this.y2 = y2;
          this.deg1 = deg1;
          this.deg2 = deg2;
     public void paintComponent(Graphics g)
      Graphics2D g2d = (Graphics2D)g;
     AffineTransform transform = new AffineTransform();
          g2d.setColor(Color.red);
         g.drawImage(back, x2, y2, this);
         //g.drawImage(tread, x-125, y-125, this);
             //g.drawImage(base, x-125, y-125, this);
             //g.drawImage(top, x-125, y-125, this);
          transform.setToTranslation(x,y-5);
          transform.rotate(Math.toRadians(deg1),tread.getWidth()/2,tread.getHeight()/2-10);
         g2d.drawImage(tread, transform, this);
             g2d.drawImage(base, transform, this);
          transform.setToTranslation(x,y);
          transform.rotate(Math.toRadians(deg2),top.getWidth()/2,top.getHeight()/2-25);
             g2d.drawImage(top, transform, this);
  public void overPaint(String back,String top,String base,String tread,int deg1,int deg2,int x,int y,int x2,int y2)
     try
          this.back = ImageIO.read(new File("Backgrounds\\"+back));
          this.top = ImageIO.read(new File("Images\\"+top));
          this.base = ImageIO.read(new File("Images\\"+base));
          //this.tread = ImageIO.read(new File("Images\\"+tread));
     catch (IOException ex) {System.out.println("Image Error");}
       this.x = x;
    this.y = y;
    this.x2 = x2;
    this.y2 = y2;
    this.deg1 = deg1;
     this.deg2 = deg2;
     repaint();
}

Similar Messages

  • Rotating Image With Reflections

    A few years back I bought a manual for Director 6.0. In the
    back of the manual there was a demo disc showing some samples of
    other people's work. One of the samples was called Big Top. It was
    a totating logo in shinny gold, and as it rotated, you would see
    reflections of objects and light on the surface. At one Time I
    asked how it was done, and was told that an ap called RayDream
    Designer could do it. I was told that in that ap, you could draw a
    3D room, with the four walls, floor and ceiling, and when you
    placed an object in the center of the room and rotated it, you
    would end up with a rotating image with the reflection from the
    walls. I never tried it, and long ago RayDream Designer stopped
    being supported. Recently, I was told that the same thing could be
    done with Photoshop or Flash, but I have not figured out how it is
    done. What I want to do, is create a 3D image of a logo in gold,
    chrome, or somethign reflective, and have it rotate with the
    reflections as it rotates. I have seen similar thing on TV
    commercials, but I think I need a little help on figuring out how
    this is done.

    A few years back I bought a manual for Director 6.0. In the
    back of the manual there was a demo disc showing some samples of
    other people's work. One of the samples was called Big Top. It was
    a totating logo in shinny gold, and as it rotated, you would see
    reflections of objects and light on the surface. At one Time I
    asked how it was done, and was told that an ap called RayDream
    Designer could do it. I was told that in that ap, you could draw a
    3D room, with the four walls, floor and ceiling, and when you
    placed an object in the center of the room and rotated it, you
    would end up with a rotating image with the reflection from the
    walls. I never tried it, and long ago RayDream Designer stopped
    being supported. Recently, I was told that the same thing could be
    done with Photoshop or Flash, but I have not figured out how it is
    done. What I want to do, is create a 3D image of a logo in gold,
    chrome, or somethign reflective, and have it rotate with the
    reflections as it rotates. I have seen similar thing on TV
    commercials, but I think I need a little help on figuring out how
    this is done.

  • Opening Images With Java

    How do you open images with Java? It is a JPEG, and as most will figure out from this post, I'm new to this. :P thanks in advance for any effort...

    Well... Can you possibly tell me what to put in (eg Source Packages) so yea... I'll look into the tutorial, but I also have another question. Would this work?
    Image img = Toolkit.getDefaultToolkit().getImage(C://desktop/[gamefolder]/[hiddenimages]/[image]);
    When [gamefolder] is the name of the folder, [hiddenimages] is the sub-folder with the images in it, and [image] is the image...

  • Can I create a rotating image with sevaral images in  Photoshop?

    I was wondering if I can  create   a rotating image with sevaral images in  Photoshop?    Much like a gif? Would this improve my page load time or would it be the same as loading a slideshow?  Here is an example of what we wanna do vacationsalabama

    Yes you can create a gif in PS to do this but it would be much easier to accomplish with some simple JQuery Image slider.
    Several examples here
    and here
    The benefit is they load faster, have speed options, and switching images out is a breeze. They can also have links asigned to the images as they appear.

  • How to set color space to JPEG image with Java advance Imaging

    How to set color space to JPEG image with Java advance Imaging.
    is there any API in JAI which support to set color space.

    I'm definately no guru, but this is how you can change it.
    CTRL + ALT + Click on the part of the component that you want to change. This brings up the Hidden Dom Inspector, background of component will be surrounded with a red outline (Make sure the red outline is surrounding the part of the tabset you want to change), Now you go to properties sheet and click the ellipses next to rules property this will pop up a dialog you look in this list (At the top) to see the default style classes that are affecting the rendering of the component outlined in red. (You will be able to select different sections of a single component) then you just rewrite the style class that you want to change in your Stylesheet (You will not find the styleclass that you want to change because it is a part of your theme .jar but as long as you name it exactly the same and place in your stylesheet it will override the theme .jar style classes) it's actually very easy -- you were right should be a piece of cake for a guru. Don't have the link handy but you can check out Winston's Blog on changing Table Formatting to get this information...It is EXTREMELY useful if you want your apps to have a custom look and not default that comes with Creator Themes.
    Hope this helps you out God knows others have helped me alot!
    Jason

  • Rotating Image with Fade Effect

    Ok looking to rotate an image with a fade effect; below is a rotating image code.
    (Wanting this effect to be transitional and smooth. Transparency? Opacity?)
    <script language="JavaScript">
    <!--
    function adArray() {
    for (i=0; i*2<adArray.arguments.length; i++) {
    this[i] = new Object();
    this[i].src = adArray.arguments[i*2];
    this[i].href = adArray.arguments[i*2+1];
    this.length = i;
    function getAdNum() {
    dat = new Date();
    dat = (dat.getTime()+"").charAt(8);
    if (dat.length == 1)
    ad_num = dat%ads.length;
    else
    ad_num = 0;
    return ad_num;
    var ads = new adArray(
    "img1.jpg","http://www.domain.com",
    "img2.jpg","http://www.domain.com",
    "img3.jpg","http://www.domain.com");
    var ad_num = getAdNum();
    document.write('<div align="center"><A HREF="'+ads[ad_num].href+'" target="_blank"><IMG SRC="'+ads[ad_num].src+'" '
    +'BORDER=0 name=js_ad></A></div>');
    link_num = document.links.length-1;
    function rotateSponsor() {
    if (document.images) {
    ad_num = (ad_num+1)%ads.length;
    document.js_ad.src = ads[ad_num].src;
    document.links[link_num].href = ads[ad_num].href;
    setTimeout("rotateSponsor()",4000);
    setTimeout("rotateSponsor()",4000);
    // -->
    </script>
    Any ideas?

    Here is the script I finally got working! It would have not came to me without your help guys!
    <script>
    var pictureWebPartName="Pictures"; // name of the picture library web part
    var showThumbnails = true; //otherwise show full sized images
    var randomImg = true; //set to true to show in random order
    var useCustomLinks = false; //true to use second column as URL for picture clicks
    var RotatingPicturesLoopTime = 5000; //2000 = 2 seconds
    var imgToImgTransition = 1.0; //2 = 2 seconds
    // don't change these
    var selectedImg = 0;
    var imgCache = [];
    var imgTag;
    function RotatingPictures()
    imgTag = document.getElementById("RotatingImage");
    //Find the picture web part and hide it
    var Imgs = [];
    var x = document.getElementsByTagName("TD"); // find all of the table cells
    var LinkList;
    var i=0;
    for (i=0;i<x.length;i++)
    if (x[i].title == pictureWebPartName)
    // tables in tables in tables... ah SharePoint!
    LinkList = x[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
    // hide the links list web part
    LinkList.style.display="none";
    break;
    if (!LinkList)
    document.all("RotatingImageMsg").innerHTML="Web Part '" + pictureWebPartName + "' not found!";
    //Copy all of the links from the web part to our array
    var links = LinkList.getElementsByTagName("TR") // find all of the rows
    var url;
    var len;
    for (i=0;i<links.length;i++)
    //if (links(i).id.match("row")!=null)
    if (links[i].childNodes[0].className=="ms-vb2")
    len=Imgs.length
    Imgs[len]=[]
    Imgs[len][0] = links[i].childNodes[0].childNodes[0].href;
    if (useCustomLinks)
    if (links[i].childNodes[1].childNodes.length>0)
    { Imgs[len][1] = links[i].childNodes[1].childNodes[0].href; }
    else
    { Imgs[len][1] = "" }
    if (Imgs.length==0)
    document.all("RotatingImageMsg").innerHTML="No images found in web part '" + pictureWebPartName + "'!";
    for (i = 0; i < Imgs.length; i++)
    imgCache[i] = new Image();
    imgCache[i].src = Imgs[i][0];
    if (useCustomLinks)
    imgCache[i].customlink=Imgs[i][1];
    RotatingPicturesLoop();
    // now show the pictures...
    function RotatingPicturesLoop()
    if (randomImg)
    selectedImg=Math.floor(Math.random()*imgCache.length);
    if (document.all){
    imgTag.style.filter="blendTrans(duration=" + imgToImgTransition + ")";
    imgTag.filters.blendTrans.Apply();
    url=imgCache[selectedImg].src
    if (useCustomLinks)
    { RotatingImageLnk.href=imgCache[selectedImg].customlink; }
    else
    { RotatingImageLnk.href = url; }
    if (showThumbnails)
    // convert URLs to point to the thumbnails...
    // from airshow%20pictures/helicopter.jpg
    // to airshow%20pictures/_t/helicopter_jpg.jpg
    url = revString(url);
    c = url.indexOf(".");
    url = url.substring(0,c) + "_" + url.substring(c+1,url.length);
    c = url.indexOf("/");
    url = url.substring(0,c) + "/t_" + url.substring(c,url.length);
    url = revString(url) + ".jpg";
    imgTag.src = url;
    if (document.all){
    imgTag.filters.blendTrans.Play();
    selectedImg += 1;
    if (selectedImg > (imgCache.length-1)) selectedImg=0;
    setTimeout(RotatingPicturesLoop, RotatingPicturesLoopTime);
    // utility function revString found here:
    // http://www.java2s.com/Code/JavaScript/Language-Basics/PlayingwithStrings.htm
    function revString(str) {
    var retStr = "";
    for (i=str.length - 1 ; i > - 1 ; i--){
    retStr += str.substr(i,1);
    return retStr;
    // add our function to the SharePoint OnLoad event
    _spBodyOnLoadFunctionNames.push("RotatingPictures");
    </script>
    <!-- add your own formatting here... -->
    <center>
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td id="VU" height="125" width="160" align="center" valign="middle">
    <a name="RotatingImageLnk" id="RotatingImageLnk" alt="click for larger picture">
    <img src="/_layouts/images/dot.gif" name="RotatingImage" id="RotatingImage" border=0>
    </a>
    <span name="RotatingImageMsg" id="RotatingImageMsg"></span>
    </td>
    </tr>
    </table>
    </center>
    Thanks again guys!

  • Problem with drawing info from mysql on an image with java

    I'm trying to draw info on a jpg with java, the info is in a mysql database with columns for what I want to draw and 2 columns for the x,y. I would be glad for any pointers, help and advice.
    1. Strangely the program draws all the info on the same spot in the image. I have no idea what I'm doing wrong.
    2. is there a way to tell java to continue drawing until there are no more rows in the database?
    I deleted the database info.
    Thanks for any help
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.*;
    import java.util.*;
    import java.sql.*;
    import javax.sql.*;
    public class carte4 {
        public static void main(String[] args)throws IOException {
        try {
    Statement stmt;
    ResultSet rs;
    com.mysql.jdbc.jdbc2.optional.MysqlDataSource ds;
    Connection conn2;
    ds = new com.mysql.jdbc.jdbc2.optional.MysqlDataSource();
    ds.setServerName("");
    ds.setDatabaseName("");
    conn2 = ds.getConnection("", "");
    stmt = conn2.createStatement();
    rs = stmt.executeQuery( "select * from territoire");
    // process results
    while (rs.next()) {
    String nom = rs.getString("nomterritoire");
    String proprio = rs.getString("nomperso");
    int unites = rs.getInt("unites");
    int coordx = rs.getInt("coordonesX");
    int coordy = rs.getInt("coordonesY");
         BufferedImage image = ImageIO.read(new File(args[0]));
    //remplire les territoires
    Graphics graphics = image.getGraphics();
              graphics.setColor(Color.black);
              graphics.drawString("a" + proprio + unites, coordx, coordy);
            graphics.drawString("b" + proprio) + unites, coordx, coordy);
            graphics.drawString("c" + proprio + unites, coordx, coordy);
              // save modified image
              String format = "JPG";
              ImageIO.write(image, format, new File(args[1]));Message was edited by:
    retosteffen

    Bill,
    Another very helpful solution and I appreciate knowing how to fix it in both applications. Thanks!
    Wolf

  • Using Javascript to rotate images with the style.backgroundImage property & I leave the onload pg & return, the images have trouble loading.

    I'm using Javascript to rotate background images -->
    function rotateImages() {
    setInterval("startRotator()", 7000);
    var counter = 0;
    function startRotator() {
    var images = ["images/finance1.jpg","images/finance2.jpg","images/finance3.jpg","images/finance4.jpg","images/finance5.jpg","images/finance6.jpg"];
    if( counter >= images.length ) {
    counter = 0;
    var image = "url('" + images[counter] + "')";
    counter++;
    document.body.style.backgroundImage=image;
    The script is triggered by the load event when the homepage loads and the script only runs on the homepage. Everything works fine upon opening the homepage.
    If I leave the home page and return, the images will have trouble loading for about 3 to 5 cycles and I'll get white backgrounds for part of the time. The same thing happens if I enter the site from a page other than the homepage and then go to the homepage.
    I discovered, however, that if I enter the site at the homepage and then leave the homepage and return using the back button, everything runs fine. Apparently it then accesses a cached version of the homepage? Seems having two cached versions creates a conflict?
    This problem only happens with Firefox (I have ver 29.0.1). It does not happen on IE ver 11, Chrome ver 34, or Safari ver 5.1.7.
    I get the same problem with XP, Win7, and Win8 but, only on Firefox.
    Can you please fix this?

    Hey, I am trying to reproduce this here: [http://jsfiddle.net/u3TLb/]
    Mozillazine forums and the [http://webcompat.com] are more specialized in Web Compatibility, please ask there as well.

  • Rotate images with Drag Layer?

    Is there any code to allow me to rotate the images that I'm
    using with the Dreamweaver Behavior "Drag Layer". I don't mean
    rotate as in change images, I mean actually rotating the image by
    dragging a selection handle any number of degrees a person wants
    to. Just like you can do in image editing programs. Besides being
    able to move images on the screen I also want people to be able to
    turn the images any way they want .
    Thanks.

    No. You woud have to do the whole thing in Flash to achieve
    something like
    this.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "rodable" <[email protected]> wrote in
    message
    news:egrfk2$o8t$[email protected]..
    > Is there any code to allow me to rotate the images that
    I'm using with the
    > Dreamweaver Behavior "Drag Layer". I don't mean rotate
    as in change
    > images, I
    > mean actually rotating the image by dragging a selection
    handle any number
    > of
    > degrees a person wants to. Just like you can do in image
    editing programs.
    > Besides being able to move images on the screen I also
    want people to be
    > able
    > to turn the images any way they want .
    > Thanks.
    >

  • How to set color depth to Bitmap image with Java advance Imaging

    i have to convert image one format ot bmp format and also set the color depth as 1 bit , 4 bit , 8 bit, 16 bit, 32 bit of image.
    has any one done this before. please help me out .

    Take a look at the example code here: http://forum.java.sun.com/thread.jsp?forum=20&thread=560573&tstart=0&trange=15
    I took an image that was 24 bits/pixel (I guess) and converted it to an indexed color model (8 bits/pixel).
    Is that what you mean? (It's also easy to convert to 16 or 15 bits/pixel: use TYPE_USHORT_565_RGB or
    TYPE_USHORT_555_RGB.)

  • Image not showing in Abobe integrated with Java WebDynPro

    Hi All,
    Image is not showing in Abobe integrated with Java WebDynPro.
    I did the following:
    Added the image field in adobe form. in URL value set the value of context node binding. Binding set to none and size set to Use Original Size.
    Then in script editor i wrote
    this.value.image.href = xfa.resolveNode(this.value.image.href).value;
    at innitialize , javascript and client.
    I can see the image from the same url context value if image field is created directly in WebDynPro View.
    Can anyone suggest what is missing?
    Thanks and Regards,
    Nuzhat

    Try changing your line of code for this one
    this.value.image.href = xfa.record.Images.URL;
    Check that the url passed by scripting is correct with a messageBox for example.
    You can also try assigning a hardcoded url at scripting level to check if its works.
    Best regards, Aldo.

  • I can't rotate images or text with two fingers on my trackpad.

    I have the most recent version of Keynote, using iOS 10.9.1 and a bluetooth trackpad.  Everything was working fine with the various gestures and now the rotation (two finger twisting) won't rotate images or text boxes.  Anybody else having this issue?  Any fixes you've seen that work?
    I've turned my bluetooth trackpad on/off.  I've checked my trackpad preferences checked/unchecked/checked.  Nothing seems to work.

    give gesture back please as soon as possible!!!

  • Couln't  save a buffered image as BMP with java 1.4

    Dear friends,
    I tried to save a buffered image as BMP with java 1.4. When I run the program ,it executes sucessfully, but no image wasn't created. When I tried the same code with java 1.5 got the right result.
    This is the code I have written.
    public static void saveBMPFile(BufferedImage bufferredImage, String fileName) throws Exception{
              // TODO Auto-generated method stub
              try {
                   Iterator iter =
                        ImageIO.getImageWritersByMIMEType("image/bmp");
              // Get first writer
                   if (iter.hasNext()) {
                        ImageWriter writer = (ImageWriter) iter.next();
                        ImageWriteParam iwp = writer.getDefaultWriteParam();
                        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
                        iwp.setCompressionType("BI_RGB");                    
                        FileImageOutputStream fios = new FileImageOutputStream(new File(fileName));
                        writer.setOutput(fios);
                        IIOImage image = new IIOImage(bufferredImage, null, null);
                        writer.write(null, image, iwp);
                        bufferredImage.flush();
                        fios.flush();
                        fios.close();
         } catch (Exception e) {                 
         throw e;
    please help me to find its solution.
    thanks & regards
    K P Jyothish

    Please use code tags http://forum.java.sun.com/help.jspa?sec=formatting
    I can see no else for "if (iter.hasNext()) {", so if no encode is found, no error message would be displayed.

  • Rotating image loaded with CameraRoll

    I'm having trouble working out how to rotate an image loaded using CameraRoll on an AIR for iOS app.
    This code below works fine (displayImage() is called when CameraRolls media event returns completed, and imageArea is the scrollPane where the image is shown.
         function displayImage():void
         var image:Bitmap = Bitmap(imageLoader.content);
         imageArea.source = image;
    The image loads just fine untill I try to rotate it:
         function readMediaData():void
         var image:Bitmap = Bitmap(imageLoader.content);
         var imX:int = image.width;
         var imY:int = image.height;
              if (imX>imY)
                  image.rotation = 90;
         imageArea.source = image;
    With the second version the image seems to load because the scroll bars expand to the size of the image I choose, but I don't see anything on the stage.
    What am I doing wrong?
    Any suggestions would be really appreciated.

    I added the new width back to images x position but no joy; no matter what x & y I set the image to, it cannot be seen. The scroll bars expand exactly the right amount for the 'invisible' image, regardless of it's x & y positions as well (you'd think if the image was out of the scrollPane the bars wouldn't adjust like that. I'm not doing something right.
    I'm stumped on this but I'll keep trying things. Thanks for your help and the lead, I appreciate it and it may be part of the problem, but there seems to be a different problem as well.

  • How to capturing scrolling images with no java controls?

    Can somebody help me? I am trying to capture the image of the browser, using the followed code to do it, but I can not take it scrolling the screen. I do not use any control of java in the browser. Does anybody have an idea?
    Robot r = new Robot();
    image1 = r.createScreenCapture(clippedScreen);
    File file = new File("c:\\Csa\\3.9\\Fimages\\"+counter+".jpg");
    javax.imageio.ImageIO.createImageOutputStream(file);
    ImageIO.write(image1,"jpg",file);
    //Scroll the screen
    scrollTheScreen ();
    //Takes scrolled area
    image2 = r.createScreenCapture(new Rectangle(0,666,1280,80));
    File file2 = new File("c:\\Csa\\3.9\\Fimages\\"+counter+1+".jpg");
    javax.imageio.ImageIO.createImageOutputStream(file2);
    ImageIO.write(image2,"jpg",file2);
    As you can see I take two parts of the screen but I am having troubles adding the images, I do not know if there is an easier way to do this.
    Thank you in advance.

    Thanks to anybody, but i found the way on how to capture the image.
    1. Take a snapshot of the screen.
    2. Scroll the screen pushing the button down.
    3. Take the snapshot of the scrolled part of the screen.
    4. Scroll the screen pushing the button down.
    5. Take the snapshot of the scrolled part of the screen.
    6. Compare the 2 last images, if they are equals, stop scrolling, else scroll again.
    7. Join the images first, second and third images, to get a single one corresponding to the hole info of the browser.
    8. Save the resulting image.
    The thing in this problem is to manage the images as RGB components for that you must use the getPixel(col, row, color); method to manipulate the components in matrix and added to a bigger matrix where you join the complete components. Be sure that you manage the 3D matrix correctly, [width of the screen] [height of the screen] [RGB components], i.e.
    * This saves just the red component, the green and blue must be saved too.
    public int[][] imreadRed(BufferedImage bi)
              Raster r = null;     // * Raster
              int [][] image;     // * Image array
              int imageWidth = bi.getWidth();     // * Image Width
              int imageHeight = bi.getHeight();     // * Image Height
              int[] color = new int[3];     // * array to colors RGB (r -> 0, g -> 1, b -> 2)
              r = bi.getData();
              image = new int[imageHeight][imageWidth];
              for(int row = 0; row < imageHeight; row++)
                   for(int col = 0; col < imageWidth; col++)
                        r.getPixel(col, row, color);
                        image[row][col] = color[0];          //Saves the red color to the array image on the first coordinate
              return image;     //Return the array with the red component
         }* This merge the matrix into a bigger one.
    public int [][] mergeMatrix (int [][] mat1, int [][] mat2){
             int rowsMat1 = (mat1.length-53), colsMat1 = mat1[0].length,     //mat1.length da los renglones de la matriz height  
             rowsMat2 = mat2.length, colsMat2 = mat2[0].length;          //mat1[0].length da las columnas de la matriz width
             int [][] addedMatrix = new int [rowsMat1+rowsMat2][colsMat1];
             for (int row = 0; row < rowsMat1; row++) {
                  for (int col = 0; col < colsMat1; col++) {
                       addedMatrix [row] [col] = mat1 [row] [col];
              for (int row=0; row < rowsMat2; row++) {
                   for (int col = 0; col < colsMat2; col++) {
                        addedMatrix [rowsMat1+row] [col]  = mat2 [row] [col];
             return addedMatrix;
        }* This convert the matrix into an image.
    public BufferedImage imwriteComponents (int [][] arrRedImg, int [][] arrGreenImg, int [][] arrBlueImg) {
              int arrayWidth = arrRedImg[0].length;     // * Image Width
              int arrayHeight = arrRedImg.length;     // * Image Height
              BufferedImage completeImage = new BufferedImage(arrayWidth, arrayHeight, BufferedImage.TYPE_INT_RGB);     // Create a BufferedImage with RGB pixels
              WritableRaster wRaster = completeImage.getRaster();     // Create a raster so we can access the BufferedImage pixels
              int [] color = new int [3];     //color variable to save all the components
              //join the 3 matrix in one color type
              for(int row = 0; row < arrayHeight; row++)
                   for(int col = 0; col < arrayWidth; col++) {
                        color [0] = arrRedImg [row][col];
                        color [1] = arrGreenImg [row][col];
                        color [2] = arrBlueImg [row][col];
                        wRaster.setPixel(col, row, color);
              return completeImage;     //Return the Buffered image with the red array component
        }That is a solution that I found to this problem, if someone has an easy way to do it please tell us.
    Thank you.

Maybe you are looking for