用于JPEG的iPhone OpenGL ES纹理管道

| 我无法让纹理管道适用于JPEG。一切都适用于PNG,但转换仍然是一个问题。 我正在通过UIImage和CGBitmapContextCreate通过图像数据加载
UIImage* tI = [UIImage imageWithContentsOfFile:fileName];
Image = tI.CGImage;

mWidth = CGImageGetWidth(Image);
mHeight = CGImageGetHeight(Image);

mData = new uint8[mWidth * mHeight * 4];

Context = CGBitmapContextCreate(mData, mWidth, mHeight, CGImageGetBitsPerComponent(Image), CGImageGetBytesPerRow(Image), 
                                CGImageGetColorSpace(Image), 
                                CGImageGetBitmapInfo(Image));

CGContextDrawImage(Context, CGRectMake(0.0, 0.0, float(mWidth), float(mHeight)), Image);
CGContextRelease(Context);
然后我通过调用设置GLTexture ...
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture->Width(), texture->Height(), 0, GL_RGB, GL_UNSIGNED_BYTE, texture->Data());
我怀疑这个glTexImage2D调用是问题所在。我一直在使用不同的组合来尝试使事情工作。 alpha的BitmapInfo状态为\'kCGImageAlphaNoneSkipLast \',因此我不确定是否应该使用RGBA和GL_UNSIGNED_SHORT_5_5_5_1,但到目前为止没有尝试过的组合。我最接近的是...
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->Width(), texture->Height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, texture->Data());
这给了我非常强烈的质感(可以辨别颜色的边缘,但是一切都太亮了) 任何帮助都会很棒。我正在使用JPEG尝试节省PNG上的空间。     
已邀请:
您的mData缓冲区太大。 JPEG图像不支持alpha,因此每个像素(RGB)只有三个分量,而PNG(RGBA)通常会使用四个分量。     

要回复问题请先登录注册