Revision 3c28857f
Added by Leszek Koltunski about 9 years ago
| src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
|---|---|---|
| 45 | 45 |
{
|
| 46 | 46 |
private GLSurfaceView mView; |
| 47 | 47 |
private DistortedBitmap monaLisa; |
| 48 |
private Static2D pLeft, pRight; |
|
| 49 |
private Static4D rLeft, rRight; |
|
| 50 |
private Dynamic3D dLeft, dRight; |
|
| 51 | 48 |
|
| 52 |
private int bmpHeight, bmpWidth; |
|
| 53 |
|
|
| 54 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 | 50 |
|
| 56 | 51 |
public MonaLisaRenderer(GLSurfaceView v) |
| 57 | 52 |
{
|
| 58 | 53 |
mView = v; |
| 59 |
|
|
| 60 |
pLeft = new Static2D( 90, 258); |
|
| 61 |
pRight= new Static2D(176, 255); |
|
| 62 |
|
|
| 63 |
rLeft = new Static4D(-10,-10,25,25); |
|
| 64 |
rRight= new Static4D( 10, -5,25,25); |
|
| 65 |
|
|
| 66 |
dLeft = new Dynamic3D(1000,0.0f); |
|
| 67 |
dRight= new Dynamic3D(1000,0.0f); |
|
| 68 |
|
|
| 69 |
dLeft.add( new Static3D( 0, 0,0) ); |
|
| 70 |
dLeft.add( new Static3D(-20,-20,0) ); |
|
| 71 |
|
|
| 72 |
dRight.add( new Static3D( 0, 0,0) ); |
|
| 73 |
dRight.add( new Static3D( 20,-10,0) ); |
|
| 74 | 54 |
} |
| 75 | 55 |
|
| 76 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 88 | 68 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 89 | 69 |
{
|
| 90 | 70 |
monaLisa.abortEffects(EffectTypes.MATRIX); |
| 91 |
|
|
| 92 |
if( bmpHeight/bmpWidth > height/width ) |
|
| 93 |
{
|
|
| 94 |
int w = (height*bmpWidth)/bmpHeight; |
|
| 95 |
float factor = (float)height/bmpHeight; |
|
| 71 |
monaLisa.move( new Static3D((width-200)/2, 10, 0) ); |
|
| 96 | 72 |
|
| 97 |
monaLisa.move( new Static3D((width-w)/2,0,0) ); |
|
| 98 |
monaLisa.scale(factor); |
|
| 99 |
} |
|
| 100 |
else |
|
| 101 |
{
|
|
| 102 |
int h = (width*bmpHeight)/bmpWidth; |
|
| 103 |
float factor = (float)width/bmpWidth; |
|
| 104 |
|
|
| 105 |
monaLisa.move( new Static3D(0,(height-h)/2,0) ); |
|
| 106 |
monaLisa.scale(factor); |
|
| 107 |
} |
|
| 108 |
|
|
| 109 | 73 |
Distorted.onSurfaceChanged(width, height); |
| 110 | 74 |
} |
| 111 | 75 |
|
| ... | ... | |
| 128 | 92 |
} |
| 129 | 93 |
catch(IOException e) { }
|
| 130 | 94 |
} |
| 131 |
|
|
| 132 |
bmpHeight = bitmap.getHeight(); |
|
| 133 |
bmpWidth = bitmap.getWidth(); |
|
| 134 |
|
|
| 135 |
monaLisa = new DistortedBitmap(bitmap, 9); |
|
| 136 |
monaLisa.distort( dLeft, pLeft , rLeft ); |
|
| 137 |
monaLisa.distort(dRight, pRight, rRight); |
|
| 95 |
|
|
| 96 |
monaLisa = new DistortedBitmap(200,200,1); |
|
| 97 |
monaLisa.setBitmap(bitmap); |
|
| 138 | 98 |
|
| 139 | 99 |
try |
| 140 | 100 |
{
|
Also available in: Unified diff
Fix the 1x1 case! Before it used to be impossible to create a DistortedBitmap just with 2 triangles!