Why would
Bitmap bmp;
bmp = Bitmap.createBitmap( 100, 100, Config.RGB_565 );
Ever return a bitmap with a height and width of -1? I don't see anything in the document开发者_开发技巧ation about this. Only see this in the documentation
Throws
IllegalArgumentException if the width or height are <= 0
But while debugging in eclipse I see the width and height are -1 after creation. Everything seems to display correctly.
[Update]
If I add a Log and get the width and height
Log.i(logTag, "bmp - (width,height) (" + bmp.getWidth() + "," + bmp.getHeight() + ")");
Then look at the properties of the bitmap, the correct width and height are shown (I'm assuming any call to read the width and height after creation would then update the properties in eclipse and it will show correctly).
I guess this is just a debugger issue? I'm debugging on my old Droid.
Are you in a situation where this is an issue? Or merely curious why they are -1?
Either way it is not a debugger issue, the properties are actually -1. This is just speculation but until the Bitmap is used/drawn the width and height can be -1 because it doesn't matter and is likely an optimization in the implementation.
精彩评论