Yes, I managed with this "problem".
I use specific drawBitmap method of Canvas class - public void
drawBitmap (Bitmap bitmap, Rect src, Rect dst, Paint paint)
Example:
Rect rect = new Rect(0, mCanvasHeight - mY, mCanvasHeight,
mBackgroundHeight - mY);
Rect rect2 = new Rect(0, 0, mCanvasWidth, mCanvasHeight);
canvas.drawBitmap(mBackgroundImage, rect, rect2, null);
//increment mY each time you need and your picture would be "moving"
forward:)

As for unexpected resizing - usual copy/paste :) - I used LunarLander
SDK example for my experiments and didn't notice this code:
  // don't forget to resize the background image
                mBackgroundImage = mBackgroundImage.createScaledBitmap
(
                        mBackgroundImage, width, height, true);

in setSurfaceSize method. So I actually worked with "updated" copy of
my background image in my code.

That's it.


On 27 апр, 05:33, Ikon <[email protected]> wrote:
> Nick, Did you figure this one out? I want to do the same.
>
> On Mar 9, 12:50 pm, Nick <[email protected]> wrote:
>
> > Hello!
> > I'm creating a simple game for Android and faced with a problem: Idea
> > is to have a huge "map" image file and re-drawonly small part of it
> > (320*480) depending on user actions.
>
> > I didn't find a better solution than using "public staticBitmap
> > createBitmap (Bitmapsource, int x, int y, int width, int height)"
> > method and decided to try it (expected huge performance degradation),
> > but actually it's appeared that this method changes sourcebitmapand
> > when i call it second time source size is significantly reduced. For
> > instance this code:
>
> > int bitHeight = mBackgroundImage.getHeight();
> > int bitWidth = mBackgroundImage.getWidth();BitmapcurMap 
> > =Bitmap.createBitmap(mBackgroundImage,
> >                 0, mY, 320, 480);
> > canvas.drawBitmap(curMap, 0, 0, null);
>
> > gives 320*960 (initial source image size) size for the first time and
> > 320*455 for the second call
>
> > I hope this is not a best solution and look forward to hearing a new
> > direction or at least clarification on createBitmap method.
>
> > p.s i'm not a native english speaker and i apologise for possible
> > mistakes.
--~--~---------~--~----~------------~-------~--~----~
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