Re: iPhone text on UIImage not getting displayed on device.
Re: iPhone text on UIImage not getting displayed on device.
- Subject: Re: iPhone text on UIImage not getting displayed on device.
- From: Alexander Spohr <email@hidden>
- Date: Tue, 19 May 2009 23:05:23 +0200
Nope. Shraddha is creating a CGBitmapContext and draws into it. That
is fine.
Shraddha, did you check the heighton the sim and device? I mean h.
CGContextShowTextAtPoint(context, 4, 130, text, strlen(text));
could go wrong, if the image is smaller than 130 pixels.
Is text non-NULL?
I use NSStrings drawInRect: methods to draw text so I can not help
with ShowText.
atze
Am 19.05.2009 um 19:40 schrieb Luke the Hiesterman:
Is this just a function you wrote? I'm guessing that's the problem.
All drawing on iPhone should be done in the drawRect: method
(declared in UIView.h). To put text in an image, you should either
add another view on top of the image (a UILabel perhaps) or subclass
UIImageView and add your text drawing in the drawRect: method.
Luke
On May 18, 2009, at 11:43 PM, Shraddha Karwan wrote:
I used the following function to add text on UIImage. I can display
the text
on iPhone Simulator but its not getting displayed on the actual
device. What
can be the cause?
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w,
colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1);
char* text = (char *)[text1
cStringUsingEncoding:NSASCIIStringEncoding];//
"05/05/09";
CGContextSelectFont(context, "Arial", 12, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 255, 255, 255, 1);
CGContextShowTextAtPoint(context, 4, 130, text, strlen(text));
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
return [UIImage imageWithCGImage:imageMasked];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden