0

このチュートリアル ( http://www.bit-101.com/blog/?p=1861 ) に従いましたが、同じ画像を複数回保存すると、品質が徐々に低下することに気付きました。

メモリ リーク以外に、何が問題なのですか? ピクセルごとに 4 バイト (rgba) をプルする必要があります。各ピクセルが考慮されている場合、損失はどこにありますか?

-----------------編集-----------------

頂点位置の変換が行われるたびに、ピクセル データから新しい画像を保存してから、この変更された画像をテクスチャ バッファーに読み込み、頂点/インデックス バッファーをリセットします。そうすれば、変更を永続的に保ち、最終的にワープの途切れを少なくすることができます。私の他の SO の質問を参照してください: OpenGL ES 2.0 Vertex Transformation Algorithms


-----------------編集-----------------

複数回保存する前に

ここに画像の説明を入力


チュートリアルのコードは次のとおりです。

-(UIImage *) glToUIImage {
    NSInteger myDataLength = 320 * 480 * 4;

    // allocate array and read pixels into it.
    GLubyte *buffer = (GLubyte *) malloc(myDataLength);
    glReadPixels(0, 0, 320, 480, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

    // gl renders "upside down" so swap top to bottom into new array.
    // there's gotta be a better way, but this works.
    GLubyte *buffer2 = (GLubyte *) malloc(myDataLength);
    for(int y = 0; y < 480; y++)
    {
        for(int x = 0; x < 320 * 4; x++)
        {
            buffer2[(479 - y) * 320 * 4 + x] = buffer[y * 4 * 320 + x];
        }
    }

    // make data provider with data.
    CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, NULL);

    // prep the ingredients
    int bitsPerComponent = 8;
    int bitsPerPixel = 32;
    int bytesPerRow = 4 * 320;
    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
    CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
    CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;

    // make the cgimage
    CGImageRef imageRef = CGImageCreate(320, 480, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);

    // then make the uiimage from that
    UIImage *myImage = [UIImage imageWithCGImage:imageRef];
    return myImage;
}

-(void)captureToPhotoAlbum {
    UIImage *image = [self glToUIImage];
    UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}
4

1 に答える 1

1

Every time you render the altered image, it is (necessartly) being resampled — that is, converted to a bitmap where the original pixels (texels) align with the screen grid other than on a 1:1 basis. This is necessarily lossy, in that you have lost some of the detail of the original image, so you will get worse results if you distort that image again, compared to transforming the original image with different parameters.

于 2012-03-20T17:52:00.000 に答える