00001 #import "ObjectiveChipmunk.h" 00002 #import "ChipmunkAutoGeometry.h" 00003 00004 #import <TargetConditionals.h> 00005 00006 #if TARGET_OS_IPHONE == 1 00007 #import <CoreGraphics/CoreGraphics.h> 00008 #endif 00009 00010 00016 @interface ChipmunkBitmapSampler : ChipmunkAbstractSampler { 00017 @private 00018 NSUInteger _width, _height, _stride; 00019 NSUInteger _bytesPerPixel, _component; 00020 00021 bool _flip; 00022 const uint8_t *_pixels; 00023 NSData *_pixelData; 00024 00025 cpFloat _borderValue; 00026 00027 cpBB _outputRect; 00028 } 00029 00031 @property(readonly) NSUInteger width; 00032 00034 @property(readonly) NSUInteger height; 00035 00037 @property(readonly) NSUInteger bytesPerPixel; 00038 00040 @property(assign) NSUInteger component; 00041 00043 @property(readonly) NSData *pixelData; 00044 00047 @property(assign) cpBB outputRect; 00048 00057 -(id)initWithWidth:(NSUInteger)width height:(NSUInteger)height stride:(NSUInteger)stride bytesPerPixel:(NSUInteger)bytesPerPixel component:(NSUInteger)component flip:(bool)flip pixelData:(NSData *)pixelData; 00058 00060 -(void)setBorderRepeat; 00061 00063 -(void)setBorderValue:(cpFloat)borderValue; 00064 00066 -(ChipmunkPolylineSet *)marchAllWithBorder:(bool)bordered hard:(bool)hard; 00067 00068 @end 00069 00070 00071 00074 @interface ChipmunkCGContextSampler : ChipmunkBitmapSampler { 00075 @private 00076 CGContextRef _context; 00077 } 00078 00080 @property(readonly) CGContextRef context; 00081 00083 @property(readonly) NSMutableData *pixelData; 00084 00087 -(id)initWithWidth:(int)width height:(int)height colorSpace:(CGColorSpaceRef)colorSpace bitmapInfo:(CGBitmapInfo)bitmapInfo component:(NSUInteger)component; 00088 00089 @end 00090 00091 00092 00094 @interface ChipmunkImageSampler : ChipmunkCGContextSampler 00095 00097 +(CGImageRef)loadImage:(NSURL *)url; 00098 00101 -(id)initWithImage:(CGImageRef)image isMask:(bool)isMask contextWidth:(NSUInteger)width contextHeight:(NSUInteger)height; 00102 00105 -(id)initWithImageFile:(NSURL *)url isMask:(bool)isMask; 00106 00109 +(ChipmunkImageSampler *)samplerWithImageFile:(NSURL *)url isMask:(bool)isMask; 00110 00111 @end