diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-11-11 11:45:53 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-11-13 11:40:33 +0100 |
commit | 319623a3345b5cb11f0d42c6e7781734ff1a3a40 (patch) | |
tree | abc95702d8c84a9b9ae41589551518a837271407 /android/source/src/java/org/libreoffice/canvas/ImageUtils.java | |
parent | 01d0983e3dd963003159779ca0920ace7dc308c4 (diff) |
android: Add bottom formatting toolbar
The bottom formatting toolbar now shows the formatting options
previously located in the main toolbar as a menu entry (bold,
italic, ...). In addition alignment options and selection of fonts
and sizes have been added.
Bottom formatting toolbar is not shown by default - it enables when
hitting the icon in main toolbar. Also soft keyboard and formatting
toolbar should not be shown at the same time.
Change-Id: I5f6cf8a9fcbdb4d154ae7504a65f9a226c99d694
Diffstat (limited to 'android/source/src/java/org/libreoffice/canvas/ImageUtils.java')
-rw-r--r-- | android/source/src/java/org/libreoffice/canvas/ImageUtils.java | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/android/source/src/java/org/libreoffice/canvas/ImageUtils.java b/android/source/src/java/org/libreoffice/canvas/ImageUtils.java index fd62444c41be..b99d4256de27 100644 --- a/android/source/src/java/org/libreoffice/canvas/ImageUtils.java +++ b/android/source/src/java/org/libreoffice/canvas/ImageUtils.java @@ -1,24 +1,31 @@ package org.libreoffice.canvas; import android.graphics.Bitmap; +import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; public class ImageUtils { - /** - * Convert transparent pixels to gray ones. - */ - public static Bitmap bitmapToPressed(Bitmap input) { - Bitmap op = Bitmap.createBitmap(input.getWidth(), input.getHeight(), input.getConfig()); - for(int i=0; i<op.getWidth(); i++){ - for(int j=0; j<op.getHeight(); j++){ - int p = input.getPixel(i, j); - // assign gray color if the pixel in input is transparent. - int newColor = Color.alpha(p) == 0 ? Color.argb(255, 200, 200, 200) : p; - op.setPixel(i, j, newColor); - } - } - - return op; + public static Bitmap getBitmapForDrawable(Drawable drawable) { + drawable = drawable.mutate(); + + int width = !drawable.getBounds().isEmpty() ? + drawable.getBounds().width() : drawable.getIntrinsicWidth(); + + width = width <= 0 ? 1 : width; + + int height = !drawable.getBounds().isEmpty() ? + drawable.getBounds().height() : drawable.getIntrinsicHeight(); + + height = height <= 0 ? 1 : height; + + final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + + return bitmap; } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |