Einzelnen Beitrag anzeigen

Micha88
(Gast)

n/a Beiträge
 
#7

AW: Zweidimensionales Array drehen

  Alt 7. Jun 2010, 12:24
Hier mal mein Code, wie ich Punkte eines Arrays um 90° drehe. (Bild)
Der Haken ist jedoch,.. das ist JAVA

Code:
public static ImageChannel turn(ImageChannel ch)
  {
    byte[] lum = ch.getIntensity();
    int iH = ch.getHeight();
    int iW = ch.getWidth();
   
   byte[] v = new byte[lum.length];
   for (int i = 0; i < iH; i++)
   {
     for (int j = 0; j < iW; j++)
     {
       v[j * iH + i] = (byte)lum[i * iW + j];
     }
   }
   
   ImageChannel chinv = new ImageChannel(v, iH, iW);   
   return chinv;
  }
  Mit Zitat antworten Zitat