Hi Iain,
On 08/13/2012 02:29 PM, Iain Billett wrote:
I've worked out a way of getting reasonable box-shadow around the page
thumbnails. Ultimately it requires pixel by pixel modification to
soften the shadow ( It was too dark before ). All the same it doesn't
seem too slow but currently the thumbnails are small. Currently, the
shadow is added at runtime as part of the grid adapter but I could
just add the shadow to the thumbnail? ( This would make it difficult
to change once added, unless we keep the original also ). I'm
really surprised that there is no clean way of doing this (that I can
see).
I don't know how your images are stored/drawn, but this is how I add
shadows in the remote control using a shadow "paint" (assuming you're
doing it in Java):
Bitmap aBitmap = getMyBitmapFromSomewhere();
final int borderWidth = 8; // However much space you want
for shadows
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setShadowLayer(borderWidth, 0, 0, Color.BLACK); // Change
the colour of the shadow here
Bitmap aOut = Bitmap.createBitmap(aBitmap.getWidth() + 2 //
The new larger bitmap containing image+shadow
* borderWidth, aBitmap.getHeight() + 2
* borderWidth, aBitmap.getConfig());
RectF aRect = new RectF(borderWidth, borderWidth,
borderWidth // This is the rectangle where the original image will be
painted
+ aBitmap.getWidth(), borderWidth
+ aBitmap.getHeight());
Canvas canvas = new Canvas(aOut);
canvas.drawColor(Color.TRANSPARENT); // Fade out to a given
background color
canvas.drawRect(aRect, p); // Draw the shadow first
canvas.drawBitmap(aBitmap, null, aRect, null); // Draw the
original image on top
return aOut; // New Bitmap with shadow.
Hope this helps,
Andrzej
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.