I hope this is an easy one, I've searched the web to no avail.
I have an array (lines) that houses more arrays (points). I want to turn this into a bmp.
This is what I have going on (more verbosely)
I have a UIImage in my UIImage view that allows the user to draw
Code:
#import <UIKit/UIKit.h>
#import "SigCap.h"
#define POINT(X) [[self.points objectAtIndex:X] CGPointValue]
UIColor *current;
@interface TouchView : UIView
{
NSMutableArray *points;
}
@property (retain) NSMutableArray *points;
@end
@implementation TouchView
@synthesize points;
NSMutableArray *lines;
+(void)viewload
{
lines=[NSMutableArray array];
[lines retain];
}
- (BOOL) isMultipleTouchEnabled {return NO;}
// Start new array
- (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event
{
self.points = [NSMutableArray array];
CGPoint pt = [[touches anyObject] locationInView:self];
[self.points addObject:[NSValue valueWithCGPoint:pt]];
}
// Add each point to array
- (void) touchesMoved:(NSSet *) touches withEvent:(UIEvent *) event
{
CGPoint pt = [[touches anyObject] locationInView:self];
[self.points addObject:[NSValue valueWithCGPoint:pt]];
[self setNeedsDisplay];
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[lines addObject:points];
NSLog(@"%@", [lines lastObject]);
}
// Draw all points
- (void) drawRect: (CGRect) rect
{
if (!self.points) return;
CGContextRef context = UIGraphicsGetCurrentContext();
[current set];
CGContextSetLineWidth(context, 1.0f);
if ([lines lastObject]) {
for (int x = 0; x<([lines count]); x++) {
for (int c = 0; c < ([[lines objectAtIndex:x]count] - 1); c++)
{
CGPoint pt1 = [[[lines objectAtIndex:x] objectAtIndex:c] CGPointValue];
CGPoint pt2 = [[[lines objectAtIndex:x] objectAtIndex:(c+1)] CGPointValue];
CGContextMoveToPoint(context, pt1.x, pt1.y);
CGContextAddLineToPoint(context, pt2.x, pt2.y);
CGContextStrokePath(context);
}
}
}
for (int i = 0; i < (self.points.count - 1); i++)
{
CGPoint pt1 = POINT(i);
CGPoint pt2 = POINT(i+1);
CGContextMoveToPoint(context, pt1.x, pt1.y);
CGContextAddLineToPoint(context, pt2.x, pt2.y);
CGContextStrokePath(context);
}
}
@end
So I get my array of arrays at the end of this, but I have no clue how to turn it into a bmp. Any help would be greatly appreciated