diff options
Diffstat (limited to 'frontends/cocoa/bitmap.m')
-rw-r--r-- | frontends/cocoa/bitmap.m | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/frontends/cocoa/bitmap.m b/frontends/cocoa/bitmap.m index fe611f118..30127e360 100644 --- a/frontends/cocoa/bitmap.m +++ b/frontends/cocoa/bitmap.m @@ -55,21 +55,21 @@ static inline NSMapTable *cocoa_get_bitmap_cache( void ) static int bitmap_get_width(void *bitmap) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; - return [bmp pixelsWide]; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; + return (int)[bmp pixelsWide]; } static int bitmap_get_height(void *bitmap) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; - return [bmp pixelsHigh]; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; + return (int)[bmp pixelsHigh]; } static bool bitmap_get_opaque(void *bitmap) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; return [bmp isOpaque]; } @@ -84,8 +84,8 @@ static void bitmap_destroy(void *bitmap) NSMapRemove( cache, bitmap ); } - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; - [bmp release]; + NSBitmapImageRep *bmp = (__bridge_transfer NSBitmapImageRep *)bitmap; + bmp = nil; } static void *bitmap_create(int width, int height, unsigned int state) @@ -103,34 +103,34 @@ static void *bitmap_create(int width, int height, unsigned int state) bytesPerRow: BYTES_PER_PIXEL * width bitsPerPixel: BITS_PER_PIXEL]; - return bmp; + return (__bridge_retained void *)bmp; } static void bitmap_set_opaque(void *bitmap, bool opaque) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; [bmp setOpaque: opaque ? YES : NO]; } static unsigned char *bitmap_get_buffer(void *bitmap) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; return [bmp bitmapData]; } static size_t bitmap_get_rowstride(void *bitmap) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; return [bmp bytesPerRow]; } static size_t bitmap_get_bpp(void *bitmap) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; return [bmp bitsPerPixel] / 8; } @@ -159,7 +159,7 @@ static bool bitmap_test_opaque(void *bitmap) static bool bitmap_save(void *bitmap, const char *path, unsigned flags) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; NSData *tiff = [bmp TIFFRepresentation]; return [tiff writeToFile: [NSString stringWithUTF8String: path] atomically: YES]; @@ -193,7 +193,7 @@ static CGImageRef cocoa_prepare_bitmap( void *bitmap ) { NSCParameterAssert( NULL != bitmap ); - NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap; + NSBitmapImageRep *bmp = (__bridge NSBitmapImageRep *)bitmap; size_t w = [bmp pixelsWide]; size_t h = [bmp pixelsHigh]; @@ -245,8 +245,8 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte cspace, kCGImageAlphaNoneSkipLast ); CGColorSpaceRelease( cspace ); - size_t width = MIN( content_get_width( content ), 1024 ); - size_t height = ((width * bheight) + bwidth / 2) / bwidth; + int width = MIN( content_get_width( content ), 1024 ); + int height = ((width * bheight) + bwidth / 2) / bwidth; CGContextTranslateCTM( bitmapContext, 0, bheight ); CGContextScaleCTM( bitmapContext, (CGFloat)bwidth / width, -(CGFloat)bheight / height ); |