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 689899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:22:49+00:00 2026-05-14T02:22:49+00:00

For my iPhone 3D apps I am currently using CoreGraphics to load png files

  • 0

For my iPhone 3D apps I am currently using CoreGraphics to load png files that have pre-multiplied alpha. Here are the essentials:

// load a 4-channel rgba png file with pre-multiplied alpha. 
CGContextRef context =  
CGBitmapContextCreate(data, width, height, 8, num_channels * width, colorSpace, 
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); 

// Draw the image into the context
CGRect rect =  CGRectMake(0, 0, width, height); 
CGContextDrawImage(context, rect, image); 
CGContextRelease(context); 

I then go on and use the data as a texture in OpenGL.

My question: By specifying pre-multiplied alpha – kCGImageAlphaPremultipliedLast – am I – inadvertently – telling CoreGraphics to multiply the r g b channels by alpha or – what I have assumed – am I merely indicating that the format of the incoming image has pre-multiplied alpha?

Thanks,
Doug

  • 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-14T02:22:49+00:00Added an answer on May 14, 2026 at 2:22 am

    By specifying pre-multiplied alpha – kCGImageAlphaPremultipliedLast – am I – inadvertently – telling CoreGraphics to multiply the r g b channels by alpha or – what I have assumed – am I merely indicating that the format of the incoming image has pre-multiplied alpha?

    Neither one. You specified the format of the destination (the context), not the source. The source—the image object—knows whether its pixels’ colors are premultiplied or not, and Quartz will use that knowledge to do the right thing when it draws the source image into the context.

    This means that the pixels in your buffer will be premultiplied—not twice, but they will be premultiplied in the context buffer, whether the source colors were premultiplied or not (if they were, no need to multiply again; if they weren’t, then it will multiply for the first time).

    I don’t know enough OpenGL to know whether that’s a problem, and if it is, there is probably no solution for this code: On the Mac, at least, Quartz does not support unpremultiplied colors in bitmap contexts.

    You might try this storage format instead.

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

Sidebar

Related Questions

What are the options for developing iPhone apps? Currently I've tried to install gnu
i have two iphone apps and want to they able to switch via a
I realise that the view/controller stuff will be different between Mac and IPhone apps
I have found the Getting Started documents for developing apps on iPhone. I wanted
A lot of iPhone apps use a blue badge to indicate the number of
Those of us with iPhone apps (released or unreleased) are able to send out
I just sat in on a seminar about developing apps for the iPhone. The
Has Mono been ported to the iPhone yet? I'd love to write .NET apps
Does iPhone support XML-RPC, Is their any open source framework which I can use?
Can iPhone applications compiled against 2.1 be successfully installed via iTunes on a 2.0

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.