Andrzej J. R. Hunt andrzej at ahunt.org
Tue Aug 14 04:15:17 PDT 2012

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 
                             + 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,


More information about the LibreOffice mailing list