added additional base index parameter to data() method of display
Stefan Schuermans

Stefan Schuermans commited on 2011-09-11 11:27:59
Showing 3 changed files, with 8 additions and 9 deletions.

... ...
@@ -97,7 +97,7 @@ public class Display
97 97
   public void dataClear()
98 98
   {
99 99
     byte [] black = {(byte)0, (byte)0, (byte)0};
100
-    data(black, 0, 0, 0, 0, m_size.m_x, m_size.m_y);
100
+    data(black, 0, 0, 0, 0, 0, m_size.m_x, m_size.m_y);
101 101
   }
102 102
 
103 103
   /**
... ...
@@ -106,12 +106,13 @@ public class Display
106 106
    *                 pixels need to be in R8G8B8 format
107 107
    * @param[in] strideX stride between two pixels in X direction
108 108
    * @param[in] strideY stride between two pixels in Y direction
109
+   * @param[in] base array index of top-left pixel
109 110
    * @param[in] x X coordinate of left side of rectangular area
110 111
    * @param[in] y Y coordinate of top side of rectangular area
111 112
    * @param[in] width with of rectangular area
112 113
    * @param[in] height height of rectangular area
113 114
    */
114
-  public void data(byte [] data, int strideX, int strideY,
115
+  public void data(byte [] data, int strideX, int strideY, int base,
115 116
                    int x, int y, int width, int height)
116 117
   {
117 118
     int dist, out, pix, i, c;
... ...
@@ -141,7 +142,7 @@ public class Display
141 142
               // check if pixel is within rectangular area of image
142 143
               if (rx >= 0 && rx < width && ry >= 0 && ry < height) {
143 144
                 // get pixel data and map it
144
-                src = rx * strideX + ry * strideY;
145
+                src = rx * strideX + ry * strideY + base;
145 146
                 distri.m_msgBuf[dest+0] = distri.m_mapRed.m_table[data[src+0] & 0xFF];
146 147
                 distri.m_msgBuf[dest+1] = distri.m_mapGreen.m_table[data[src+1] & 0xFF];
147 148
                 distri.m_msgBuf[dest+2] = distri.m_mapBlue.m_table[data[src+2] & 0xFF];
... ...
@@ -59,7 +59,7 @@ public class Blink
59 59
     for (i = 0; i < 5; ++i) {
60 60
 
61 61
       System.out.println("on");
62
-      display.data(white, 0, 0, 0, 0, width, height);
62
+      display.data(white, 0, 0, 0, 0, 0, width, height);
63 63
       display.send();
64 64
       try {
65 65
         Thread.sleep(500);
... ...
@@ -71,12 +71,10 @@ public class Fade
71 71
     display.data(image,
72 72
                  3,              // consecutive pixels are 3 bytes apart
73 73
                  width * 3,      // consecutive lines are width * 3 bytes apart
74
-                 0, 0, width, height);
74
+                 0,              // top-left pixel is at array index 0
75
+                 0, 0,           // top-left pixel is 0,0
76
+                 width, height); // image size is width,height
75 77
     display.send();
76
-    try {
77
-      Thread.sleep(500);
78
-    } catch (InterruptedException e) {
79
-    }
80 78
 
81 79
     // free display
82 80
     display = null;
83 81