objective c - Image rotating left when taking picture with iPad -
in application i'm working @ can take picture ipad camera. after using coregraphics can draw shapes on image.
@ first image upside down , mirrored. resolved this:
cgcontexttranslatectm(mycontext, 0, backgroundimage.size.height); cgcontextscalectm(mycontext, 1.0, -1.0);
but when take image in portrait mode, imported image rotated left (so it's presented horizontally). rotated image code:
uiimage *tempimage = [[uiimage alloc] initwithcgimage:imagetest.cgimage]; cgaffinetransform transform = cgaffinetransformidentity; transform = cgaffinetransformtranslate(transform, 0, tempimage.size.height); transform = cgaffinetransformrotate(transform, -m_pi_2); cgcontextref ctx = cgbitmapcontextcreate(null, tempimage.size.width, tempimage.size.height, cgimagegetbitspercomponent(tempimage.cgimage), 0, cgimagegetcolorspace(tempimage.cgimage), cgimagegetbitmapinfo(tempimage.cgimage)); cgcontextconcatctm(ctx, transform); cgcontextdrawimage(ctx, cgrectmake(0,0,tempimage.size.height,tempimage.size.width), tempimage.cgimage); cgimageref cgimg = cgbitmapcontextcreateimage(ctx); uiimage *img = [uiimage imagewithcgimage:cgimg]; cgcontextrelease(ctx); cgimagerelease(cgimg);
now image shown in right way (portrait), can't draw on it, maybe because width , height reversed.
from read there meta tag image orientation cannot read coregraphics.
do know better way rotate image? or solution keep image rotating when taking photo in portrait mode?
yes issue because default orientation of device camera landscape, if take picture in portrait mode , see preview in photo gallery fine, use in app rotated 90 degrees, fix issue have written answer in recent post here
Comments
Post a Comment