0

Im kinda new to Android programming, so perhaps Im missing something. In my code, im trying to create new bitmap by invoking Bitmap.createBitmap(W, H, Bitmap.Config.ARGB_8888). It returns bitmap with size of (-1, -1) for any W and H other than 640x480. Is there any reason why am I allowed to create only bitmap with fixed size?

Expro
  • 143
  • 3
  • draw bitmap with convas. – Habib Zare Jan 20 '13 at 03:43
  • you created an empty bitmat.you can draw on it by convas.[example](http://stackoverflow.com/questions/4918079/android-drawing-a-canvas-to-an-imageview) – Habib Zare Jan 20 '13 at 03:45
  • Are you specifying any layout parameter? If layout parameter is wrap_content then width and height could be negative as well. – VendettaDroid Jan 20 '13 at 03:57
  • Im using this bitmap as target for processed camera frame. Still, I dont know why creating bitmap with size of 640x480 works properly (created object got same size), but using any other numbers result in creation of invalid bitmap. – Expro Jan 20 '13 at 12:23

1 Answers1

1

If you do Bitmap.createBitmap(W, H, Bitmap.Config.ARGB_8888) then it will create a "mutable bitmap with the specified width and height. Its initial density is as per getDensity()". Mutable bitmaps are the once that could be modified. So, as Habib mentioned you can draw a bitmap using Canvas.

VendettaDroid
  • 3,131
  • 2
  • 28
  • 41