mask

How to get a CGImageRef from Context-Drawn Images?

醉酒当歌 提交于 2019-12-05 02:11:39
Ok using coregraphics, I'm building up an image which will later be used in a CGContextClipToMask operation. It looks something like the following: UIImage *eyes = [UIImage imageNamed:@"eyes"]; UIImage *mouth = [UIImage imageNamed:@"mouth"]; UIGraphicsBeginImageContext(CGSizeMake(150, 150)); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(context, 0, 0, 0, 1); CGContextFillRect(context, bounds); [eyes drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1]; [mouth drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1]; // how can i now get a CGImageRef here

Auto-Resize UITableView Headers on Rotate (Mostly on iPad)

瘦欲@ 提交于 2019-12-05 00:45:17
I feel like this is going to be a simple answer revolving around AutoResizingMasks, but I can't seem to wrap my head around this topic. I've got an iPad app that shows 2 UITableViews side-by-side. When I rotate from Portrait to Landscape and back, the cells in the UITableView resize perfectly, on-the-fly, while the rotation is occurring. I'm using UITableViewCellStyleSubtitle UITableViewCells (not subclassed for now), and I've set the UITableView up in IB to anchor to the top, left and bottom edges (for the left UITableView) and to have a flexible width. I'm supplying my own UIView object for

PorterDuff masking leaves opaque black background

↘锁芯ラ 提交于 2019-12-04 19:26:52
I'm trying to mask a FrameLayout with a mask defined as a nine patch. However, although it works fine on 5.0+ on older versions (such as 4.4.4), the patch leaves an opaque black background. Is there anything that can be done to avoid this other than drawing to an off screen bitmap before rendering to the screen or reverting to software layers? public class MaskedLayout extends FrameLayout { private final static PorterDuffXfermode DST_IN = new PorterDuffXfermode(PorterDuff.Mode.DST_IN); private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private NinePatchDrawable mMask; private

OpenGL - don't write depth if alpha

孤人 提交于 2019-12-04 19:13:05
What I'm want to do in OpenGL using C++ and GLSL: When texture has alpha (texture.a! = 1.0;) then this pixel is not written to the depth buffer. (for color buffer it is written) Write depth occurs only when a pixel texture.a == 1.0; Discarding in shader is not a solution - then this pixel is not written to color buffer. Any ideas? @UPDATE: Example: I've got some UI images rendered by OpenGL. Some of them have alpha in corners. In scene rendering I have "depth prepass" to save some pixels by not calculating light on them. I want to also get UI images to that prepass - but only completely opaque

advanced usage of matlab roipoly command

半世苍凉 提交于 2019-12-04 19:05:20
I am new to matlab and am working on Image processing. I am using the roipoly function to create a mask. As I understand I can use it like this : I = imread('eight.tif'); c = [222 272 300 270 221 194]; r = [21 21 75 121 121 75]; BW = roipoly(I,c,r); figure, imshow(I) figure, imshow(BW) The image is shown below : One observation I had was that the interpolation between the adjacent points as specified by the c & r matrix is done by 'Linear Interpolation', in other sense always a straight line is drawn between the points. Can it be possible that somehow other types of interpolation are

Drawing UIImage mask with GestureRecognizer

三世轮回 提交于 2019-12-04 18:51:21
I'm trying to combine 2 mechanisms and I'm not getting very far on finding a solution. This is what I want to be able to do :- I have a routine that allows me to draw a mask on a UIImage layer which has a 2nd UIImage below which contains the image I am drawing the mask on top of. This seems to work fine and when I'm fininihed I just combine to 2 layers which then apply the mask and the image looks 'cut-out'. The problem is I want to be able to zoom, pan the mask and the image to be able to apply a more accurate mask in the zoomed mode. Part of the app uses GestureRecognizers to move an image

problems with 'mask' in firefox

佐手、 提交于 2019-12-04 17:43:26
I'm at the end of my rope here. This 'mask' should work right? Well, I'm beginning to doubt. My example is at http://50.63.191.172/mask.html . I really don't know what else I could try. I do have some constraints: I would like to have the svg external to any html page / css stylesheet because it will be used from multiple places. I would like to have svg non size predetermined, because I don't want to have multiple versions for various sizes; there should be only one, so that it can be cached by browsers. I can't have the image specified inside the svg. The svg is a styling to be applied to

Is there an inverse to the CSS “Clip” property; hide the clipped area?

心不动则不痛 提交于 2019-12-04 16:27:56
问题 The CSS clip syntax gets you to define a rectangular area of a larger image that you wish to be visible. Is there a way to specify the inverse? Specify the rectangular area of the image that you wish to become invisible. Like punching a rectangular hole through the page to see what's underneath? Reason (if you have any other ideas): I want to create a 3 layer image in a CMS template. Layer 1 (at the bottom) is a background image. Layer 2 sits over a portion of layer 1 and is a rectangular

gdal ReadAsarray for vrt extremely slow

淺唱寂寞╮ 提交于 2019-12-04 12:25:34
I am trying to simply subtract two rasters and save the result in another raster. One of the input images is a tif-file, the other is a vrt-file. (Output is tif) The files are very big, so I open them, divide them into tiles and run through each of them and then subtracting. The problem is that it is extremely slow! import gdal import numpy as np rA = gdal.Open(raFileName) rB = gdal.Open(rbFileName) nodataA = rA.GetRasterBand(1).GetNoDataValue() nodataB = rB.GetRasterBand(1).GetNoDataValue() raster = gdal.GetDriverByName('GTiff').Create(outputFileName, ncols, nrows, 1 ,gdal.GDT_Float32,[

UIImage masking problems iOS 7

血红的双手。 提交于 2019-12-04 10:06:37
问题 I have heavily borrowed (standard) code which applies a grayscale UIImage mask to a UIImage. - (void) maskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGImageRef imageRef = image.CGImage; // main UIImage CGImageRef maskRef = maskImage.CGImage; // grayscale UIImage mask CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider