comparison ios/dw.m @ 2437:929ce3cd18ea

iOS: Fix bitblt and crashes due to missing retains.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 06 Apr 2021 09:19:06 +0000
parents ab36fbb50fe5
children f273dbf1312f
comparison
equal deleted inserted replaced
2436:ab36fbb50fe5 2437:929ce3cd18ea
1167 CGContextRef context = _dw_draw_context(bltdest, NO); 1167 CGContextRef context = _dw_draw_context(bltdest, NO);
1168 1168
1169 if(context) 1169 if(context)
1170 UIGraphicsPushContext(context); 1170 UIGraphicsPushContext(context);
1171 1171
1172 if(bltdest && [bltsrc isMemberOfClass:[UIImage class]]) 1172 if(bltdest && [bltsrc isMemberOfClass:[DWImage class]])
1173 { 1173 {
1174 UIImage *rep = bltsrc; 1174 DWImage *rep = bltsrc;
1175 UIImage *image = [[UIImage alloc] initWithCGImage:[rep CGImage]]; 1175 UIImage *image = [rep image];
1176 CGBlendMode op = kCGBlendModeNormal; 1176 CGBlendMode op = kCGBlendModeNormal;
1177 1177
1178 if(bltinfo->srcwidth != -1) 1178 if(bltinfo->srcwidth != -1)
1179 { 1179 {
1180 [image drawInRect:CGRectMake(bltinfo->xdest, bltinfo->ydest, bltinfo->width, bltinfo->height) 1180 [image drawInRect:CGRectMake(bltinfo->xdest, bltinfo->ydest, bltinfo->width, bltinfo->height)
1185 { 1185 {
1186 [image drawAtPoint:CGPointMake(bltinfo->xdest, bltinfo->ydest) 1186 [image drawAtPoint:CGPointMake(bltinfo->xdest, bltinfo->ydest)
1187 /*fromRect:CGRectMake(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)*/ 1187 /*fromRect:CGRectMake(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)*/
1188 blendMode:op alpha:1.0]; 1188 blendMode:op alpha:1.0];
1189 } 1189 }
1190 [bltsrc release];
1191 [image release];
1192 } 1190 }
1193 if(context) 1191 if(context)
1194 UIGraphicsPopContext(); 1192 UIGraphicsPopContext();
1195 free(bltinfo); 1193 free(bltinfo);
1196 } 1194 }
1515 CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); 1513 CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
1516 CGContextRef cgcontext = CGBitmapContextCreate(NULL, size.width, size.height, 8, 0, rgb, kCGImageAlphaPremultipliedFirst); 1514 CGContextRef cgcontext = CGBitmapContextCreate(NULL, size.width, size.height, 8, 0, rgb, kCGImageAlphaPremultipliedFirst);
1517 CGImageRef cgimage = CGBitmapContextCreateImage(cgcontext); 1515 CGImageRef cgimage = CGBitmapContextCreateImage(cgcontext);
1518 image = [UIImage imageWithCGImage:cgimage]; 1516 image = [UIImage imageWithCGImage:cgimage];
1519 CGContextRelease(cgcontext); 1517 CGContextRelease(cgcontext);
1518 [image retain];
1520 } 1519 }
1521 return self; 1520 return self;
1522 } 1521 }
1523 -(id)initWithCGImage:(CGImageRef)cgimage 1522 -(id)initWithCGImage:(CGImageRef)cgimage
1524 { 1523 {
1558 /* Create a new UIImage from the CGContext via CGImage */ 1557 /* Create a new UIImage from the CGContext via CGImage */
1559 cgimage = CGBitmapContextCreateImage(cgcontext); 1558 cgimage = CGBitmapContextCreateImage(cgcontext);
1560 image = [UIImage imageWithCGImage:cgimage]; 1559 image = [UIImage imageWithCGImage:cgimage];
1561 CGContextRelease(cgcontext); 1560 CGContextRelease(cgcontext);
1562 cgcontext = nil; 1561 cgcontext = nil;
1562 [image retain];
1563 [oldimage release]; 1563 [oldimage release];
1564 } 1564 }
1565 return image; 1565 return image;
1566 } 1566 }
1567 -(CGContextRef)cgcontext 1567 -(CGContextRef)cgcontext