开发者

Positioning Bitmap on Canvas

开发者 https://www.devze.com 2023-03-01 13:25 出处:网络
forgive me if its a simple question but I am stuck. I am trying to set the position of my image to the left of the screen by certain distance (-150).

forgive me if its a simple question but I am stuck. I am trying to set the position of my image to the left of the screen by certain distance (-150). It works fine with positive numbers, but not with negative. I am drawing it on canvas since I will be adding more images to the resultant bitmap (result) later. Here is my code

     Bitmap image2=resizedbitmap;

     result = Bitmap.createBitmap(image2.getWidth(), image2.getHeight(),             `   `Bitmap.Config.ARGB_8888);        
     canvas = new 开发者_开发知识库Canvas(result);//Create the canvas to an image                
     srcRect = new Rect(-150, 0, result.getWidth(), result.getHeight());//does not work with negative numbers
     destRect = new Rect(srcRect);
     destRect.offset(0, 0);//if negative cuts the image
     canvas.drawBitmap(image2, srcRect, destRect, null);

Am I missing something? Any help appreciated. Many tnx in advance


rather using this, see here Image in Canvas with touch events

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号