I can get the size of the wallpaper from the wallpaper manager:

            m_context = app.getApplicationContext();
            WallpaperManager wpMngr = WallpaperManager.getInstance(
m_context );
            m_intWPheight = wpMngr.getDesiredMinimumHeight();
            m_intWPwidth  = wpMngr.getDesiredMinimumWidth();

I can then get the size of the display area:

            Display display = app.getWindowManager().getDefaultDisplay();
            m_intScrWidth = display.getWidth();
            m_intScrHeight = display.getHeight();

I have my image that I want to rescale:

            m_bmpImage = BitmapFactory.decodeResource( m_res, intResId );
            m_intImgWidth  = m_bmpImage.getWidth();
            m_intImgHeight = m_bmpImage.getHeight();

Scaling from the Image height to the display height:

            m_fltSFbyHeight = (float)m_intScrHeight / (float)m_intImgHeight;

What I want to do is create a black bitmap that is the same size as the
wallpaper ( intWPwidth, m_intWPheight ), then copy/blit into this bitmap the
bitmap to use as the wallpaper re-scaling it to fit if required, so I end up
with a bitmap image the same size as the wallpaper with the image centered
and scaled in the middle of it.

Thank you.


On Sun, Apr 24, 2011 at 6:39 PM, Simon Platten <[email protected]
> wrote:

>  Sorry, I should have included the code to resize, once I calculate the new
> width and height I call:
>
>         return Bitmap.createScaledBitmap(m_bmpImage,
>                                         m_intFinalWidth,
>                                         m_intFinalHeight,
>                                         false);
>
>
>
> On 24/04/2011 6:34 PM, Simon Platten wrote:
>
> When using the code on Android 1.6 platforms, the bitmaps are re-sized as
> aspected, however when used on Android 2.1 its as if the function to rescale
> has no effect what so ever, the wallpapers always come out the wrong size.
>
>
> On Sun, Apr 24, 2011 at 9:12 AM, Simon Platten <
> [email protected]> wrote:
>
>> On Android 1.6 my wallpaper applications resize the wallpapers correctly,
>> however on Android 2.1 the resizing doesn't work, its the same on the
>> emulator.
>>
>> I've tried using both the Matrix and Bitmap.createScaledBitmap both do
>> exactly the same and work find on 1.6.  Can anyone explain what is happing
>> and why these routines don't work on Android 2.1?
>>
>> I start off by getting the device screen size using:
>>
>>             Display display = app.getWindowManager().
>> getDefaultDisplay();
>>             m_intScrWidth = display.getWidth();
>>             m_intScrHeight = display.getHeight();
>>
>> I load the image from a resource with:
>>
>>             m_bmpImage = BitmapFactory.decodeResource( m_res, intResId );
>>             m_intImgWidth  = m_bmpImage.getWidth();
>>             m_intImgHeight = m_bmpImage.getHeight();
>>             m_fltSFbyHeight = (float)m_intScrHeight /
>> (float)m_intImgWidth;
>>
>> Then to scale the image:
>>
>>         m_intFinalWidth  = (int)((float)m_intImgWidth * m_fltSFbyHeight);
>>         m_intFinalHeight = (int)((float)m_intImgHeight * m_fltSFbyHeight);
>>
>> Thank you,
>> Simon
>>
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to