title: Loading 4-channel texture data in iOS
body: <p>I want to load 4-channel texture data from a file in iOS, so I consider the texture as a (continuous) map</p>
  
  <pre><code>[0,1]x[0,1] -&gt; [0,1]x[0,1]x[0,1]x[0,1]
  </code></pre>
  
  <p>If I use the fileformat <code>.png</code>, XCode/iOS consider the file as an image, and so multiplies each component <code>rgb</code> with <code>a</code> (premultiplied alpha), corrupting my data. How should I solve this? Examples may be</p>
  
  <ul>
  <li>use two textures with components <code>rgb</code> (3-channel)</li>
  <li>postdivide alpha</li>
  <li>use another file format</li>
  </ul>
  
  <p>Of these, I consider the best solution to be to use another file format. The GL-compressed file format (PVRTC?) is not Apple-platform independent and seems to be of low resolution (4 bits) (<a href="https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/TechniquesForWorkingWithTextureData/TechniquesForWorkingWithTextureData.html#//apple_ref/doc/uid/TP40008793-CH104-SW3" rel="noreferrer">reference</a>).</p>
  
  <p>EDIT:
  If my own answer below is true, it is not possible to get the 4 channel data of png's in iOS. Since OpenGL is about creating images rather than presenting images, it should be possible to load 4-channel data in some way. png is a fileformat for images (<del>and compression depends on all 4 channels</del> but compression of one channel is independent of the other channels), so one may argue that I should use another file format. So which other compressed file formats should I use, which is easy to read/integrated in iOS?</p>
  
  <p>UPDATE: "combinatorial" mentioned a way to load 4-channel non-premultiplied textures, so I had to give him the correct answer. However, that solution had some restrictions I didn't like. My next question is then "Access raw 4-channel data from png files in iOS" :)</p>
  
  <p>I think it is a bad library design not making it possible to read 4 channel png data. I don't like systems trying to be smarter than myself. </p>