uiimage - Iphone - Masking JPG images -


i coding jigsaw puzzle , need mask images create puzzle pieces.

i using pictures online server , *.jpg. when mask them, area should transparent black.

can add alpha channel programmatically? if yes, can show me how?

thanks lot, andrei

i found answer:

cgimageref imageref = self.cgimage; size_t width = cgimagegetwidth(imageref); size_t height = cgimagegetheight(imageref);  // bitspercomponent , bitmapinfo values hard-coded prevent "unsupported parameter combination" error cgcontextref offscreencontext = cgbitmapcontextcreate(null,                                                       width,                                                       height,                                                       8,                                                       0,                                                       cgimagegetcolorspace(imageref),                                                       kcgbitmapbyteorderdefault | kcgimagealphapremultipliedfirst);  // draw image context , retrieve new image, have alpha layer cgcontextdrawimage(offscreencontext, cgrectmake(0, 0, width, height), imageref); cgimageref imagerefwithalpha = cgbitmapcontextcreateimage(offscreencontext); uiimage *imagewithalpha = [uiimage imagewithcgimage:imagerefwithalpha];  // clean cgcontextrelease(offscreencontext); cgimagerelease(imagerefwithalpha);  return imagewithalpha; 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -