core-graphics

CABasicAnimation - transform scale keep in center

旧巷老猫 提交于 2021-02-06 09:48:05
问题 Trying to animatie an ellipse masked on a UIView to be scale transformed remaining in the center position. I have found CALayer - CABasicAnimation not scaling around center/anchorPoint, and followed by adding a bounds property to the maskLayer CAShapeLayer however, this ends with the mask being positioned in the left corner with only 1/4 of it showing. I would like the mask to remain within the center of the screen. @synthesize maskedView; - (void)viewDidLoad { [super viewDidLoad];

What is the equivalent of CGImageCreateWithImageInRect in MonoTouch?

我与影子孤独终老i 提交于 2021-02-05 03:54:21
问题 What is the equivalent of CGImageCreateWithImageInRect iOS method in MonoTouch? I'm trying to convert this Objective-C line in C#: CGImageRef sampleImageRef = CGImageCreateWithImageInRect(self.CGImage, fillRect); Thanks in advance! 回答1: The CoreGrapphics function CGImageCreateWithImageInRect correspond to the WithImageInRect method of CGImage . API signature is: public CGImage WithImageInRect (RectangleF rect) Once translated from ObjectiveC your source code should look like: CGImage

What is the equivalent of CGImageCreateWithImageInRect in MonoTouch?

霸气de小男生 提交于 2021-02-05 03:50:47
问题 What is the equivalent of CGImageCreateWithImageInRect iOS method in MonoTouch? I'm trying to convert this Objective-C line in C#: CGImageRef sampleImageRef = CGImageCreateWithImageInRect(self.CGImage, fillRect); Thanks in advance! 回答1: The CoreGrapphics function CGImageCreateWithImageInRect correspond to the WithImageInRect method of CGImage . API signature is: public CGImage WithImageInRect (RectangleF rect) Once translated from ObjectiveC your source code should look like: CGImage

UIScrollView draw ruler using drawRect

狂风中的少年 提交于 2021-01-29 10:48:49
问题 I am trying to draw a ruler on top of UIScrollView. The way I do it is by adding a custom view called RulerView. I add this rulerView to superview of scrollView setting its frame to be same as frame of scrollView. I then do custom drawing to draw lines as scrollView scrolls. But the drawing is not smooth, it stutters as I scroll and the end or begin line suddenly appears/disappears. What's wrong in my drawRect? class RulerView: UIView { public var contentOffset = CGFloat(0) { didSet { self

How to avoid image color profile conversion in CoreGraphics

断了今生、忘了曾经 提交于 2021-01-29 10:41:04
问题 In my application I am rendering graphics into a block of main memory using the CPU (please don't challenge this requirement). When it is time to draw this on the screen, the following code is used in order to blit a rectangular portion of this memory to the screen via "attaching" a NSBitmapImageRep to it: void* offsetBuffer = reinterpret_cast<void*>(_buffer + sourceY * bpr + sourceX * 4); unsigned char** planes = (unsigned char**)&offsetBuffer; NSRect destRect; destRect.origin.x = destX;

Why does MagnificationGesture only update the state once in SwiftUI?

限于喜欢 提交于 2021-01-29 09:16:57
问题 I wish to have the following view respond to the magnification gestures, but it only works the first time. The view can be magnified as expected, but after the view is released, subsequent touches do not trigger the gesture. Is there a way to have the gesture work continuously? struct Card: View { @State var magScale: CGFloat = 1 var magnification: some Gesture { MagnificationGesture().onChanged { gesture in magScale = gesture } } var body: some View { Rectangle() .frame(width: 200, height:

quartz device behaving strangely after mac update - R mac

自古美人都是妖i 提交于 2021-01-29 05:03:55
问题 I recently got a new macbook pro (2020 13-inch, running Big Sur v 11.1) and am using Rstudio (V 1.3.1093 with R version 4.0.3). On my old computer, I often used the quartz() function to view my plots in the external graphics viewer. On my old mac, this would allow me to dynamically resize, keep fonts consistent, save directly from the resized version, etc. Now, on my new computer, it is behaving... strangely. For example, when I run quartz() and a window opens, then I run a ggplot , the

Empty CGContext

一曲冷凌霜 提交于 2021-01-29 03:25:52
问题 In Objective-C I was able to use CGBitmapContextCreate to create an empty context. I am trying to to the same in Swift 3, but for some reason it is nil. What am I missing? let inImage: UIImage = ... let width = Int(inImage.size.width) let height = Int(inImage.size.height) let bitmapBytesPerRow = width * 4 let bitmapByteCount = bitmapBytesPerRow * height let pixelData = UnsafeMutablePointer<UInt8>.allocate(capacity: bitmapByteCount) let context = CGContext(data: pixelData, width: width, height

Empty CGContext

送分小仙女□ 提交于 2021-01-29 03:18:03
问题 In Objective-C I was able to use CGBitmapContextCreate to create an empty context. I am trying to to the same in Swift 3, but for some reason it is nil. What am I missing? let inImage: UIImage = ... let width = Int(inImage.size.width) let height = Int(inImage.size.height) let bitmapBytesPerRow = width * 4 let bitmapByteCount = bitmapBytesPerRow * height let pixelData = UnsafeMutablePointer<UInt8>.allocate(capacity: bitmapByteCount) let context = CGContext(data: pixelData, width: width, height

UIView drawHierarchy creating a black image

回眸只為那壹抹淺笑 提交于 2021-01-28 00:55:55
问题 I am trying to convert my custom UIView into UIImage using core graphic, but sometimes it turns to black, my whole UIImage looks like a black image. What I noticed is that if the height of my UIView is exceeding 4096 regardless what the width is then the produced UIImage will be black! Note 1: my custom UIView is loaded from a nib file. Here is my code: func getImageWithScale(_ scale: CGFloat) -> UIImage { let size = self.bounds.size.applying(CGAffineTransform(scaleX: scale, y: scale))