Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange crash of CGContextDrawImage



Dear all,

 

What I am doing is to create an image of a string with a font (such as “NewText” with “Monaco”) and draw the image onto the screen.

And everything is going well when the image is small, but the image size becomes bigger when I enlarge the font size, and when the image width is larger than 170, the function CGContextDrawImage() crashes.

 

I have no idea why does this happen, and my source is basically written like below:

         CGContextRef bitmapContext = CreateBitmapContext(textRect.size.width, textRect.size.height, bitmapData);

         CGContextSelectFont(bitmapContext, fontNameArray, fontSize, kCGEncodingMacRoman); 

         CGContextSetCharacterSpacing (bitmapContext, 0.0);

         CGContextSetTextDrawingMode (bitmapContext, kCGTextFill);

         CGContextSetRGBFillColor (bitmapContext, strColor->red / 65535.0, strColor->green / 65535.0, strColor->blue / 65535.0, 1.0);

         

         ATSUSetAttributes(...);

         ATSUCreateTextLayoutWithTextPtr(...);

         ATSUSetLayoutControls(atsulayout, ... , &&bitmapContext);

         ATSUDrawText(atsulayout, ...)

 

         // CGBitmapContextCreateImage() works perfect here on 10.4 but I cannot use CGBitmapContextCreateImage() on 10.3

         CGBitmapContextGet...() // Get all param of the CGContextRef

         providerRef = CGDataProviderCreateWithData(NULL, pSrcData, ulSrcDataSize, NULL);

         cgImageRef = CGImageCreate(uiWidth, uiHeight, iBPCpnt, iBPPixel, uiSrcBPL, cs, bi, providerRef, 0, FALSE, kCGRenderingIntentDefault);

 

         CGContextSaveGState(context);

         // Do the transformation

         DoTransformation(context, bounds); // Do some translate, rotate, scale, density-change

         // Draw the image centered in the context

         imageRect.origin.x = 0.0f;

         imageRect.origin.y = 0.0f;

         imageRect.size.width = CGImageGetWidth(cgImageRef);

         imageRect.size.height = CGImageGetHeight(cgImageRef);

         CGContextDrawImage(context, imageRect, cgImageRef);

         // Restore our original graphics state.

         CGContextRestoreGState(context);

 

 

Here is the crash report:

Thread 0 Crashed:

0   com.apple.CoreGraphics               0x936bb974 ARGB32_image_mark_RGB32 + 0x254

1   com.apple.CoreGraphics               0x936a0c88 ARGB32_image + 0x754

2   libRIP.A.dylib                   0x907355ac ripd_Mark + 0x38

3   libRIP.A.dylib                   0x90735e88 ripl_BltImage + 0x774

4   libRIP.A.dylib                   0x90734b80 ripc_DrawImageObject + 0x688

5   libRIP.A.dylib                   0x90736264 ripc_DrawImage + 0x144

6   com.apple.CoreGraphics               0x9369ee7c CGContextDrawImage + 0x17c

 

 

We have to support 10.3, so I have changed the way to get the CGImageRef. (Use CGImageCreate instead of CGBitmapContextCreateImage)

I doubt the way I use CGImageCreate() cause this crash, but it’s strange that when the font size is small, it works well.

So is there anyone here know why?

 

Thanks,

 

Best Regards,

Kevin
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.