Snowman
Snowman

Reputation: 32081

GlPaint not accepting my image for brush

Ok I'm not sure how much details I can really give, but I'm having a crazy weird problem. I'm using the GLPaint code in my app from Apple, and the PaintingView.m code is the same exact code from Apple-nothing else. Yesterday, everything was working fine and the brush image for the paint was a circular particle that came with the GLPaint, and it was working fine.

Now, out of nowhere, the particle is just a square, and a square particle means that the GLPaint app can't find my particle-meaning if I just put any file name into here: brushImage = [UIImage imageNamed:@"Particle.png"].CGImage; I'll get a square particle.

So this is something wrong. However, I just have no idea why. I tried replacing the Particle.png image over again and placing it in different places in my Xcode project but that didn't work. I know it's a long shot, but does anyone have ANY possible ideas as to why this could happen?

Upvotes: 0

Views: 342

Answers (2)

Snowman
Snowman

Reputation: 32081

Well I figured out the problem and I'll post the solution just in case anyone ever has an issue like this. Turns out I had a duplicate painting view in IB that for some reason maybe confused the painting view class. All I had to do was delete one of the views, then everything worked fine again.

Upvotes: 0

Alex Nichol
Alex Nichol

Reputation: 7510

If you have replaced Particle.png with an image that is not square, and the sides are not a power of two, then it will not work. For instance, the particle image can be 32x32, or 64x64, but not 110x110.

As for debugging, I would suggest putting a breakpoint at the line after brushImage = [UIImage imageNamed...], and check the value of brushImage. If you are not comfortable using the debugger, just throw NSLog(@"%p", brushImage) right under that line. If the image is nil, or 0x0, then you know that the image file cannot be found or decoded. If it is not, then the problem is in the code, not the setup.

Upvotes: 2

Related Questions