Quick fix for upside down thumbnails.

Change-Id: I089c78f050fbea068b394de9205322dc62e28764
This commit is contained in:
Iain Billett 2012-08-02 17:47:48 +01:00 committed by Michael Meeks
parent 12fff840ab
commit 36e1debe4a
4 changed files with 33 additions and 13 deletions

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:type="radial"
android:gradientRadius="200"
android:startColor="#FF000000"
android:endColor="#00FFFFFF"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="8dp" />
</shape>

View file

@ -8,16 +8,15 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/grid_item_image"
android:layout_width="100dp"
android:layout_height="142dp"
android:paddingTop="15dp"
android:paddingBottom="10dp"
android:scaleType="fitStart"
android:layout_gravity="center" >
android:layout_gravity="center">
</ImageView>
<TextView
@ -27,6 +26,7 @@
android:text="@+id/label"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:layout_gravity="center"
android:textSize="15dp"
android:textStyle="bold"

View file

@ -33,6 +33,7 @@ import org.libreoffice.R;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
@ -1110,22 +1111,21 @@ public class DocumentLoader
// Could easily make a new (larger) thumb but recycling
// should be faster & more efficient, better for the environment ;-)
//ll = (LinearLayout)findViewById( R.id.navigator);
// Bitmap bmp = ( (ThumbnailView)ll.getChildAt( 0 ) ).getBitmap();
ByteBuffer bb = renderPage( 0 , 100 , (int)( 100*Math.sqrt(2) ) );
// bb.flip();
Bitmap bmp = Bitmap.createBitmap( 100, (int)( 100*Math.sqrt(2) ), Bitmap.Config.ARGB_8888);
bmp.copyPixelsFromBuffer(bb);
Bitmap bmpAlpha = ( (ThumbnailView)ll.getChildAt( 0 ) ).getBitmap();
//For now use these 3 lines to turn the bitmap right way up.
Matrix m = new Matrix();
m.preScale( 1.0f , -1.0f );
Bitmap bmp = Bitmap.createBitmap( bmpAlpha, 0, 0, bmpAlpha.getWidth(), bmpAlpha.getHeight(), m, true);
File file = new File(extras.getString("input"));
Log.i(TAG ,"onDestroy " + extras.getString("input"));
File dir = file.getParentFile();
File thumbnailFile = new File( dir , "." + file.getName().split("[.]")[0] + ".png");
try {
/*(ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
if( !thumbnailFile.isFile() )
thumbnailFile.createNewFile();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 40, bytes);
thumbnailFile.createNewFile();
FileOutputStream fo = new FileOutputStream( thumbnailFile );
fo.write(bytes.toByteArray());*/
if( !thumbnailFile.isFile() )

View file

@ -38,6 +38,7 @@ import android.app.ActionBar.OnNavigationListener;
import android.app.Activity;
import android.os.AsyncTask;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -855,11 +856,15 @@ class ListItemAdapter implements ListAdapter{
ByteBuffer bb = renderPage( 0 , widthInPx , heightInPx);
Bitmap bm = Bitmap.createBitmap( widthInPx , heightInPx , Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(bb);
Matrix m = new Matrix();
m.preScale( 1.0f , -1.0f );
Bitmap bmp = Bitmap.createBitmap( bm, 0, 0, bm.getWidth(), bm.getHeight(), m, true);
File dir = file.getParentFile();
File thumbnailFile = new File( dir , "." + file.getName().split("[.]")[0] + ".png");
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 40, bytes);
bmp.compress(Bitmap.CompressFormat.PNG, 40, bytes);
thumbnailFile.createNewFile();
FileOutputStream fo = new FileOutputStream( thumbnailFile );
fo.write(bytes.toByteArray());