core-graphics

Producing CCITT compressed TIFF from CGImage

百般思念 提交于 2019-12-06 07:27:19
I have a CGImage (core graphics, C/C++). It's grayscale. Well, originally it was B/W, but the CGImage may be RGB. That shouldn't matter. I want to create a CCITT-Group 4 TIFF. I can create an LZW TIFF (grayscale or color) via creating a destination with the correct dictionary and adding the image in. No problem. However, there doesn't seem to be an equivalent kCGImagePropertyTIFFCompression value to represent CCITT-4. It should be 4, but that produces uncompressed. I have a manual CCITT compression routine, so if I can get the binary (1 bit per pixel) data, I'm set. But I can't seem to get 1

RGB Data from CGImage in Swift

坚强是说给别人听的谎言 提交于 2019-12-06 07:27:11
I've tried to build reading RGB pixel data in Swift. Getting the basic Image Information is no problem, but I think I've got something wrong with the pointer and the byte-offset: let provider:CGDataProviderRef = CGImageGetDataProvider(inImage) let data:NSData = CGDataProviderCopyData(provider) let bytes: COpaquePointer = data.bytes // Needs to be changed to ConstUnsafePointer<()> in xCode beta3 let bytePointer = UnsafePointer<UInt8>(bytes) println("Pixel Data:\n") var printString:String = "" for var row:Int = 0; row < Int(height); row++ { for var col:Int = 0; col < Int(width); col++ { var

Xcode - Draw Circle Around Centre

走远了吗. 提交于 2019-12-06 07:23:32
问题 I was wondering how to draw a circle around a point taken from a control's positioning. This is not working as hoped CGContextRef contextRef = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(contextRef, 2.0); CGContextSetRGBFillColor(contextRef, 0, 0, 1.0, 1.0); CGContextSetRGBStrokeColor(contextRef, 0, 0, 1.0, 1.0); CGRect circlePoint = (CGRectMake(self.frame.size.width / 2, self.frame.size.height / 2, 10.0, 10.0)); CGContextFillEllipseInRect(contextRef, circlePoint); 回答1: I think its

Does CGContextSetTextMatrix work for offscreen bitmaps?

青春壹個敷衍的年華 提交于 2019-12-06 07:23:17
I'm creating an image offscreen using a context from CGBitmapContextCreate() . While drawing text, I tried to use the: CGContextSetTextMatrix(contextRef, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0)); but my text was still upside down. If I used the standard transforms it was correct: CGContextTranslateCTM(contextRef, 0.0, contextRect.size.height); CGContextScaleCTM(contextRef, 1.0, -1.0); My question is should the CGContextSetTextMatrix work for an offscreen bitmap? Maybe I was doing something wrong. No. The text matrix, as its name says, only affects text. All drawing goes through

iOS - Fill Animation of a UIBezierPath from bottom

◇◆丶佛笑我妖孽 提交于 2019-12-06 06:32:02
I have a UIBezierPath inside custom UIView , draw() . I want to fill that path, lets say a rectangle from bottom to top. How can I implement this. From Here I have seen using CAShapeLayer its possible. That is working fine with animation but filling is not happening from bottom to top on the rectangle. Please guide. Is this what you are asking for? func zoom() { let startPath = UIBezierPath(rect: CGRect(x: 0, y: self.frame.size.height-30, width: self.frame.size.width, height: 30)) let endPath = UIBezierPath(rect: CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height))

How to free memory in ARC for high memory usage graphics render?

落花浮王杯 提交于 2019-12-06 05:50:05
问题 First off, thank you to everyone on this site...it's been INCREDIBLY helpful in getting into the grit of iOS programming. My current issue: I have an app that renders a very stylized version of a photo. It uses some CoreImage filters for some of it, but needs a bunch of CoreGraphics to get the heavy image processing done. The proxy size renders work out great, but when I render a full resolution version of my image, it sometimes crashes because of high memory usage. The problem is that I need

NSString drawInRect:withAttributes: not correctly centered when using NSKernAttributeName

白昼怎懂夜的黑 提交于 2019-12-06 05:48:21
问题 When I use drawInRect:withAttributes: and pass in both a paragraph style with NSTextAlignmentCenter and a non-zero value for NSKernAttributeName , the string does not get centered correctly. Am I doing something wrong or is this expected behavior? Is there a workaround? Screenshot: You can clearly see that top text is not centered correctly. My demo code: - (void)drawRect:(CGRect)rect { // Drawing code UIFont *font = [UIFont systemFontOfSize:15.0]; [self drawString:@"88" inRect:rect font:font

programmatically generate ppt in iOS

痴心易碎 提交于 2019-12-06 05:47:40
For generating PDF files we can use Core Graphics. Similarly is there any framework / class that can be used for generating .ppt (power point presentation) files via code ? Or is there any third party framework for this purpose. There's no in-built Apple API, and I've never heard of a third-party framework for this. Seems there are still no open source solutions for this for iOS platform. Aspose seems to have something and another commercial that pretty recently emerged - libpptx.com , at least it provides some generic functionality to craft pptx 来源: https://stackoverflow.com/questions

High-performance copying of RGB pixel data to the screen in iOS

Deadly 提交于 2019-12-06 04:47:39
Our product contains a kind of software image decoder that essentially produces full-frame pixel data that needs to be rapidly copied the screen (we're running on iOS). Currently we're using CGBitmapContextCreate and we access the memory buffer directly, then for each frame we call CGBitmapContextCreateImage, and then draw that bitmap to the screen. This is WAY too slow for full-screen refreshes on the iPad's retina display at a decent framerate (but it was okay for non-Retina-devices). We've tried all kinds of OpenGL ES-based approaches, including the use of glTexImage2D and glTexSubImage2D

CGPath adding a curve between points

只谈情不闲聊 提交于 2019-12-06 04:34:27
问题 So I have a function which randomly generates some CGPoints I then create a CGPath from these points. I use this path in a keyframe animation to animate a view around the screen. The path is generated using the code below: - (CGMutablePathRef)generatePathFromCoordinates:(NSArray *)coordinates { CGMutablePathRef path = CGPathCreateMutable(); CGPoint point = [(NSValue *)[coordinates objectAtIndex:0] CGPointValue]; CGPathMoveToPoint(path, nil, point.x, point.y); for (int i=1; i < coordinates