don't flip image on mapshot

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5681 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Alejandro V. Garcia
2010-09-01 21:10:29 +00:00
parent 636ca1ecc9
commit 94bfc29811
+11 -10
View File
@@ -387,7 +387,7 @@ void jpeg_screenshot(const char *imagepath, bool mapshot = false)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, minimaptex);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGR, GL_UNSIGNED_BYTE, pixels);
}
else
{
@@ -400,16 +400,17 @@ void jpeg_screenshot(const char *imagepath, bool mapshot = false)
{
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, iw, ih, GL_BGR, GL_UNSIGNED_BYTE, pixels);
int stride = 3*iw;
GLubyte *swapline = (GLubyte *) malloc(stride);
for(int row = 0; row < ih/2; row++)
{
memcpy(swapline, pixels + row * stride, stride);
memcpy(pixels + row * stride, pixels + (ih - row - 1) * stride, stride);
memcpy(pixels + (ih - row -1) * stride, swapline, stride);
}
}
int stride = 3*iw;
GLubyte *swapline = (GLubyte *) malloc(stride);
for(int row = 0; row < ih/2; row++) {
memcpy(swapline, pixels + row * stride, stride);
memcpy(pixels + row * stride, pixels + (ih - row - 1) * stride, stride);
memcpy(pixels + (ih - row -1) * stride, swapline, stride);
}
const char *filename = screenshotpath(imagepath, "jpg");
if(save_jpeg(filename, pixels, iw, ih, jpegquality) < 0) conoutf("\f3Error saving jpeg file");