Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6243465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:08:42+00:00 2026-05-24T12:08:42+00:00

I followed Apple’s GLPaint paint application and tried to modify it.. In sample code

  • 0

I followed Apple’s GLPaint paint application and tried to modify it.. In sample code they have used simple particle.png to draw.

Before modification

My question is i want to use some other image of my choice for drawing. At first sight it seems very easy to replace “particle.png” with some “finger.png” but it did not work.. When I replaced “particle.png” with “finger.png” , I got something like this :

After replacing particle.png

My “finger.png” image looks somthing like this :

enter image description here

Link : http://developer.apple.com/library/ios/#samplecode/GLPaint/Listings/Classes_PaintingView_m.html#//apple_ref/doc/uid/DTS40007328-Classes_PaintingView_m-DontLinkElementID_6

Partial Code:

- (id)initWithCoder:(NSCoder*)coder 
{

CGSize          myShadowOffset = CGSizeMake (0,  0);


 NSMutableArray*     recordedPaths;
 CGImageRef          brushImage;
 CGContextRef     brushContext;
 GLubyte               *brushData;
 size_t               width, height;


      // Create a texture from an image
      // First create a UIImage object from the data in a image file, and then extract the Core Graphics image

   ////--------------------Modification--------------------------------///////    

        brushImage = [UIImage imageNamed:@"finger.png"].CGImage;  


  ////--------------------Modification--------------------------------///////     



     // Get the width and height of the image
      width = CGImageGetWidth(brushImage);
      height = CGImageGetHeight(brushImage);
      NSLog(@"%f%f",(CGFloat)width, (CGFloat)height);
      // Texture dimensions must be a power of 2. If you write an application that allows users to supply an image,
      // you'll want to add code that checks the dimensions and takes appropriate action if they are not a power of 2.

      // Make sure the image exists
      if(brushImage) 
    {
           // Allocate  memory needed for the bitmap context
           brushData = (GLubyte *) calloc(width * height * 4, sizeof(GLubyte));
           // Use  the bitmatp creation function provided by the Core Graphics framework. 
           brushContext = CGBitmapContextCreate(brushData, width, height, 8, width * 4, CGImageGetColorSpace(brushImage), kCGImageAlphaPremultipliedLast);
           // After you create the context, you can draw the  image to the context.
           CGContextDrawImage(brushContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), brushImage);
           // You don't need the context at this point, so you need to release it to avoid memory leaks.

        CGContextRelease(brushContext);
           // Use OpenGL ES to generate a name for the texture.
           glGenTextures(1, &brushTexture);
           // Bind the texture name. 
           glBindTexture(GL_TEXTURE_2D, brushTexture);
           // Set the texture parameters to use a minifying filter and a linear filer (weighted average)
           glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
           // Specify a 2D texture image, providing the a pointer to the image data in memory
           glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, brushData);
           // Release  the image data; it's no longer needed
        free(brushData);
  }

I do not understand why I am getting drawing like this. Can anyone point me out that what other changes I need to make to make this application work as before?? I am not expert at OpenGL so any help or suggestion will be appreciated..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:08:42+00:00Added an answer on May 24, 2026 at 12:08 pm

    If I remember correctly, you have to make the image white on transparent in order for it to work. If you have blue with transparency around it, it will show the entire picture as opaque.

    I took the standard Apple GLPaint app. I replaced particle.png with a finger.png that I made in Photoshop. It is 64×64 RGB 8 bits. The entire image is transparent except for a white smudge which I copied directly from your blue finger.png. Here is the output in the simulator:
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the NameAndPassword Auth Plugin sample code from Apple to create my
I have followed Apple's documentation on localizing iPhone software, using the genstrings ruby script
I have followed the Apple documentation and I am having no success: - (NSString
I have been playing with some of Apple's example code for customizing UITableViewCells. I
I followed the apple tutorial Your First iOS Application step by step and it
I have followed this tutorial: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 fully, and after seing that I had issues
I'm a complete beginner to Apple's Xcode, but I have followed the Xcode documentation
I followed below code to establish https connection in my application to fetch some
I have followed all the Apple documentation for setting up a service for a
I followed this tutorial for push notification. http://mobiforge.com/developing/story/programming-apple-push-notification-services . In my didFinishLaunchingWithOptions i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.