ios - UIGraphicsBeginContext, UIGraphicsEndImageContext in Cocoa? -
ios - UIGraphicsBeginContext, UIGraphicsEndImageContext in Cocoa? -
i'm porting bits of ios app osx , have code creates nsimage @ runtime. i'm having problem converting cocoa osx. help cocoa equivalents of uigraphicsbeginimagecontext, uigraphicsgetimagefromcurrentimagecontext , uigraphicsendimagecontext?
- (uiimage *)progressimage:(double)progress size: size { cgfloat height = size.height; cgfloat width = size.width; uigraphicsbeginimagecontext(cgsizemake(width, height)); cgcontextref context = uigraphicsgetcurrentcontext(); // grayness background cgcontextsetrgbfillcolor(context, 102.0 / 255.0, 102.0 / 255.0, 102.0 / 255.0, 1.0); cgcontextfillrect(context, cgrectmake(0.0, 0.0, width, height)); // orange progress cgcontextsetrgbfillcolor(context, 241.0 / 255.0, 89.0 / 255.0, 42.0 / 255.0, 1.0); cgcontextfillrect(context, cgrectmake(0.0, 0.0, width * (cgfloat) progress, height)); uiimage *resultingimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); homecoming resultingimage; }
the quartz 2d programming guide should help.
take @ nsgraphicscontext basic equivalent of uigraphicsgetcurrentcontext().
ios objective-c osx cocoa nsimage
Comments
Post a Comment