Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 12    Views: 83

mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
04/08/13 08:00 PM (12 years ago)

Paint Plugin custom background?

I'm building a face paint info app and was wondering if it is at all possible to use a png image instead of the white canvas within this plugin?
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/08/13 08:40 PM (12 years ago)
I was looking into it on other forums and came across this little snippet which is to be placed in PaintView.m directly after the line cacheContext... CGContextDrawImage(cacheContext, self.bounds, [UIImage imageName:@"myimage.png"].CGImage); But not being a coder have no idea how to declare this method? BTW here is the other forum link for reference.. http://www.effectiveui.com/blog/2011/12/02/how-to-build-a-simple-painting-app-for-ios/ Cheers Mick
 
aussiedra
Code is Art
Profile
Posts: 431
Reg: Dec 25, 2010
Brisbane, Austr...
8,260
like
04/08/13 09:00 PM (12 years ago)
just have a look at plugins with background images and apply the same. on the road at the mo but will shoot ya one if no one else answer.
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/08/13 10:46 PM (12 years ago)
Thanks @aussiedra but fiddling around with that line of code I pasted in the above post works (albeit upside-down) after I put a 'd' after 'imageName' cleared the reference that makes the background white and put #import <QuartzCore/QuartzCore.h> into the top of the PaintView.h file. eg.. CGContextDrawImage(cacheContext, self.bounds, [UIImage imageNamed:@"face.png"].CGImage); I now only have a yellow semantic issue pointing at the } directly below it. (Control may reach end of non-void function). But I'm cheering that I have gotten this far with it! Now I will photoshop with the correct dimensions an upside down face.png file and done!
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/08/13 10:52 PM (12 years ago)
Semantic issue gone after typing in "return YES;" after png line. eg.. cacheContext = CGBitmapContextCreate (cacheBitmap, size.width, size.height, 8, bitmapBytesPerRow, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst); //Draw an image from project as background. CGContextDrawImage(cacheContext, self.bounds, [UIImage imageNamed:@"face.png"].CGImage); return YES; } Hope this helps someone:) Mick
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
04/08/13 10:53 PM (12 years ago)
I've been somewhat working through it as well. As I need it for landscape too. MadRod has it working in one of his apps. I'll post back after Ive given it a proper go.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
04/08/13 10:54 PM (12 years ago)
Awesome! Does it work in landscape for you also?
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/08/13 10:56 PM (12 years ago)
Fantastic!
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/08/13 10:57 PM (12 years ago)
Sorry I haven't yet tested landscape? Leave it with me.
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/08/13 11:10 PM (12 years ago)
Come to think of it I really don't want this screen to rotate from portrait as my image is just of a face outline to practice designs on, if it were to rotate the image would distort badly.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
04/09/13 05:17 AM (12 years ago)
this: //Draw an image from project as background. CGContextDrawImage(cacheContext, self.bounds, [UIImage imageNamed:@"face.png"].CGImage); is what I used in my original code however i was only able to paint on 3/4 of the screen. did you see that issue @mikeoz?
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/09/13 04:01 PM (12 years ago)
Hi @mysps, I will be doing more extensive testing with this plugin today, but in iphone/ipad 6.1/5.1 in simulator no problem so far? I have only tested on an Iphone 4s with 6.1.3 and that seems fine also no 3/4 limitation? Did you import Quartzcore into the .h file by any chance? Mick
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/09/13 09:04 PM (12 years ago)
I managed to get my greasy mits on an iPad2 6.1.3 for testing and found that the paint screen rotates to landscape and like @mysps said the far right 1/4 is unusable. How far have you guys gotten with this problem? Is it something to do with the coordinates, as it seems like the image axis is on the top left corner and the image does not refresh to fit screen in landscape mode? As my app does not need landscape for anything in particular should I just switch off those orientations for distribution? Cheers Mick
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.