From 82f65054561020d38e37dd376e4f652dcd1bcca8 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 30 May 2012 23:11:22 +0300 Subject: Progress finally Now I get (a page of) the document rendered into a bitmap. Unfortunately css.awt.XBitmap::getDIB() provides an in-core 24-bit (BGR) BMP file. (Yes, despite the name, it's not just the DIB, but is prefixed with a BMP file header.) Android's Image class wants RGBA. Hmm. Change-Id: Ie0effef20751e1959644861af358d81538b6d6ea --- .../android/examples/DocumentLoader.java | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'android/experimental/DocumentLoader') diff --git a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java index ac9516443f29..c39741e9f93d 100644 --- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java +++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java @@ -105,7 +105,7 @@ public class DocumentLoader } } - static void dump(String objectName, Object object) + static void dumpUNOObject(String objectName, Object object) { Log.i(TAG, objectName + " is " + (object != null ? object.toString() : "null")); @@ -128,6 +128,17 @@ public class DocumentLoader Log.i(TAG, " " + t.getTypeName()); } + static void dumpBytes(byte[] image) + { + for (int i = 0; i < 160; i += 16) { + String s = ""; + for (int j = 0; j < 16; j++) + s = s + String.format(" %02x", image[i+j]); + + Log.i(TAG, s); + } + } + @Override public void onCreate(Bundle savedInstanceState) { @@ -207,7 +218,7 @@ public class DocumentLoader xCompLoader.loadComponentFromURL (sUrl, "_blank", 0, loadProps); - dump("oDoc", oDoc); + dumpUNOObject("oDoc", oDoc); // Test stuff, try creating various services, see what types // they offer, stuff that is hard to find out by reading @@ -219,12 +230,12 @@ public class DocumentLoader xCompLoader.loadComponentFromURL ("private:factory/swriter", "_blank", 0, loadProps); - dump("swriter", swriter); + dumpUNOObject("swriter", swriter); Object frameControl = xMCF.createInstanceWithContext ("com.sun.star.frame.FrameControl", xContext); - dump("frameControl", frameControl); + dumpUNOObject("frameControl", frameControl); com.sun.star.awt.XControl control = (com.sun.star.awt.XControl) UnoRuntime.queryInterface(com.sun.star.awt.XControl.class, frameControl); @@ -232,14 +243,14 @@ public class DocumentLoader Object toolkit = xMCF.createInstanceWithContext ("com.sun.star.awt.Toolkit", xContext); - dump("toolkit", toolkit); + dumpUNOObject("toolkit", toolkit); com.sun.star.awt.XToolkit xToolkit = (com.sun.star.awt.XToolkit) UnoRuntime.queryInterface(com.sun.star.awt.XToolkit.class, toolkit); com.sun.star.awt.XDevice device = xToolkit.createScreenCompatibleDevice(1024, 1024); - dump("device", device); + dumpUNOObject("device", device); // I guess the XRenderable thing might be what we want to use, // having the code pretend it is printing? @@ -262,6 +273,14 @@ public class DocumentLoader Log.i(TAG, "getRendererCount: " + renderBabe.getRendererCount(oDoc, renderProps)); renderBabe.render(0, oDoc, renderProps); + + com.sun.star.awt.XBitmap bitmap = device.createBitmap(0, 0, 1024, 1024); + + byte[] image = bitmap.getDIB(); + + Log.i(TAG, "image is " + image.length + " bytes"); + + dumpBytes(image); } } catch (Exception e) { -- cgit