diff options
author | Tor Lillqvist <tlillqvist@suse.com> | 2012-05-30 23:11:22 +0300 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2012-05-31 00:00:51 +0300 |
commit | 82f65054561020d38e37dd376e4f652dcd1bcca8 (patch) | |
tree | 44f77a672dee7d150803b731de2c3de379f68db4 /android | |
parent | d69bcc9979f56ab5dc59b9d10bbc601d38506873 (diff) |
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
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java | 31 |
1 files changed, 25 insertions, 6 deletions
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) { |