現在、glreadpixels()を使用して画面をキャプチャしています。キャプチャされた画像は一般的に鏡像であるため、画像を通常の状態に戻しました。次に、キャプチャしたデータ(画像)を90度回転させます。それを行う方法はありますか?
画面データをキャプチャするために使用するコードは次のとおりです。
CGRect screenBounds = [[UIScreen mainScreen] bounds];
int backingWidth = screenBounds.size.width;
int backingHeight =screenBounds.size.height;
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
NSInteger myDataLength = backingWidth * backingHeight * 4;
GLuint *buffer;
if((buffer= (GLuint *) malloc(myDataLength)) == NULL )
NSLog(@"error initializing the buffer");
glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// code for flipping back (mirroring the image data)
for(int y = 0; y < backingHeight / 2; y++) {
for(int xt = 0; xt < backingWidth; xt++) {
GLuint top = buffer[y * backingWidth + xt];
GLuint bottom = buffer[(backingHeight - 1 - y) * backingWidth + xt];
buffer[(backingHeight - 1 - y) * backingWidth + xt] = top;
buffer[y * backingWidth + xt] = bottom;
}
}
バッファにキャプチャされたデータを90度回転させる方法はありますか?ありがとう