Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 05-24-2011, 08:15 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 10
kylej is on a distinguished road
Default Converting array of CGPoints to a bmp

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
kylej is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 393
20 members and 373 guests
Absentia, AyClass, baja_yu, checkright, Diligent, dre, fvisticot, givensur, jbro, jPuzzle, momolgtm, Newbie123, Paul10, Punkjumper, revg, sacha1996, skrew88, taylor202, tomtom100
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,858
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:39 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0