android - Canvas returns black image on rotate -
i'm ussing opencv, face recognizer project example one, made robotic apps team, android, camera not expected, rotation has bugs , in order rotate camera view use in portrait orientation, have rotate canvas inside of camerabridgeviewbase class in deliveranddrawframe method, have next canvas rotation method:
canvas.drawcolor(0, android.graphics.porterduff.mode.clear); canvas.rotate(180); mscale = canvas.getwidth() / (float) mcachebitmap.getheight(); float scale2 = canvas.getheight() / (float) mcachebitmap.getwidth(); if (scale2 > mscale) { mscale = scale2; } if (mscale != 0) { canvas.scale(mscale, mscale, 0, 0); } log.d(tag, "mstretch value: " + mscale); canvas.drawbitmap(mcachebitmap, 0, -mcachebitmap.getheight(), null); // ...
when use rotate method value 90 canvas.rotate(90); returns image rotated 90 degrees expected, when rotate more 90 or less 90 like, 0, -90, 180, 270, etc. it returns black image :(
what's problem code?
it coordinant system. canvas property has fill style default:"black". since image gets out of scene have black image. in situation rotating around (0,0). should change image's origin middle of image(width/2,height/2).
Comments
Post a Comment