用于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上的空间。
没有找到相关结果
已邀请:
1 个回复
爆刺疤灯