commit 79f172ab724539b99fbdeb49a47dd358d2d7bcc9
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Sun Aug 7 23:50:55 2016 +0100

    Fix the 1x1 case! Before it used to be impossible to create a DistortedBitmap just with 2 triangles!

diff --git a/src/main/java/org/distorted/library/DistortedBitmap.java b/src/main/java/org/distorted/library/DistortedBitmap.java
index ec5f2c8..d628cea 100644
--- a/src/main/java/org/distorted/library/DistortedBitmap.java
+++ b/src/main/java/org/distorted/library/DistortedBitmap.java
@@ -73,9 +73,9 @@ public class DistortedBitmap extends DistortedObject
      int xsize = cols;
      int ysize = cols*height/width;
 
-     if( xsize<2   ) xsize=  2;
+     if( xsize<1   ) xsize=  1;
      if( xsize>256 ) xsize=256;
-     if( ysize<2   ) ysize=  2;
+     if( ysize<1   ) ysize=  1;
      if( ysize>256 ) ysize=256;
      
      mSizeX= width;
diff --git a/src/main/java/org/distorted/library/DistortedBitmapGrid.java b/src/main/java/org/distorted/library/DistortedBitmapGrid.java
index 30c13bf..45ba0f3 100644
--- a/src/main/java/org/distorted/library/DistortedBitmapGrid.java
+++ b/src/main/java/org/distorted/library/DistortedBitmapGrid.java
@@ -30,28 +30,27 @@ class DistortedBitmapGrid extends DistortedObjectGrid
   private int remainingVert;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// create a flat, full grid
+// Create a flat, full grid. cols and rows is guaranteed (by DistortedBitmap constructor)
+// to be in 1,2,...,256.
 
    private void computeNumberOfVertices(int cols, int rows)
      {
-     //android.util.Log.e("BITMAP","preparing data structures, cols="+cols+" rows="+rows);
+     mRows=rows;
+     mCols=cols;
 
-     mRows     =0;
-     mCols     =0;
-     dataLength=0;
-
-     if( cols>0 )
+     if( cols==1 && rows==1 )
+       {
+       dataLength = 4;
+       }
+     else
        {
-       mCols = cols;
-       mRows = rows;
-
        dataLength = 2*( mRows*mCols +2*mRows - 1) +2*(mCols>=2 ? mRows:0) +
                     (mCols>=2 && mRows>=2 ? 2*mRows-2 : 1);
+       }
 
-       //android.util.Log.e("BITMAP","vertices="+dataLength);
+     //android.util.Log.e("BITMAP","vertices="+dataLength+" rows="+mRows+" cols="+mCols);
 
-       remainingVert = dataLength;
-       }
+     remainingVert = dataLength;
      }
 
 
@@ -139,6 +138,21 @@ class DistortedBitmapGrid extends DistortedObjectGrid
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+   private static String debug(float[] val, int stop)
+     {
+     String ret="";
+
+     for(int i=0; i<val.length; i++)
+        {
+        if( i%stop==0 ) ret+="\n";
+        ret+=(" "+val[i]);
+        }
+
+     return ret;
+     }
+*/
+///////////////////////////////////////////////////////////////////////////////////////////////////
 
 /**
  * Creates the underlying grid of vertices, normals and texture coords.
@@ -156,12 +170,10 @@ class DistortedBitmapGrid extends DistortedObjectGrid
 
       buildGrid(positionData,normalData,textureData);
 
-      /*
-      android.util.Log.e("CUBES","dataLen="+dataLength+" vertex="+numVertices);
-      android.util.Log.d("CUBES", "position: "+debug(positionData,3) );
-      android.util.Log.d("CUBES", "normal: "  +debug(  normalData,3) );
-      android.util.Log.d("CUBES", "texture: " +debug( textureData,2) );
-      */
+      //android.util.Log.e("CUBES","dataLen="+dataLength);
+      //android.util.Log.d("CUBES", "position: "+debug(positionData,3) );
+      //android.util.Log.d("CUBES", "normal: "  +debug(  normalData,3) );
+      //android.util.Log.d("CUBES", "texture: " +debug( textureData,2) );
 
       android.util.Log.d("BITMAP", "remainingVert " +remainingVert );
 
