Skip to content

Commit 149cc52

Browse files
committed
Remove old BMP screenshot code
1 parent 4a9b6ff commit 149cc52

File tree

2 files changed

+0
-276
lines changed
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient

2 files changed

+0
-276
lines changed

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,144 +2879,6 @@ static void CreateBMPFile(LPTSTR pszFile, char *image, Int width, Int height)
28792879
LocalFree( (HLOCAL) pbmi);
28802880
}
28812881

2882-
///Save Screen Capture to a file
2883-
void W3DDisplay::takeScreenShot(void)
2884-
{
2885-
char leafname[256];
2886-
char pathname[1024];
2887-
2888-
static int frame_number = 1;
2889-
2890-
Bool done = false;
2891-
while (!done) {
2892-
#ifdef CAPTURE_TO_TARGA
2893-
sprintf( leafname, "%s%.3d.tga", "sshot", frame_number++);
2894-
#else
2895-
sprintf( leafname, "%s%.3d.bmp", "sshot", frame_number++);
2896-
#endif
2897-
strlcpy(pathname, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(pathname));
2898-
strlcat(pathname, leafname, ARRAY_SIZE(pathname));
2899-
if (_access( pathname, 0 ) == -1)
2900-
done = true;
2901-
}
2902-
2903-
// TheSuperHackers @bugfix xezon 21/05/2025 Get the back buffer and create a copy of the surface.
2904-
// Originally this code took the front buffer and tried to lock it. This does not work when the
2905-
// render view clips outside the desktop boundaries. It crashed the game.
2906-
SurfaceClass* surface = DX8Wrapper::_Get_DX8_Back_Buffer();
2907-
2908-
SurfaceClass::SurfaceDescription surfaceDesc;
2909-
surface->Get_Description(surfaceDesc);
2910-
2911-
SurfaceClass* surfaceCopy = NEW_REF(SurfaceClass, (DX8Wrapper::_Create_DX8_Surface(surfaceDesc.Width, surfaceDesc.Height, surfaceDesc.Format)));
2912-
DX8Wrapper::_Copy_DX8_Rects(surface->Peek_D3D_Surface(), NULL, 0, surfaceCopy->Peek_D3D_Surface(), NULL);
2913-
2914-
surface->Release_Ref();
2915-
surface = NULL;
2916-
2917-
struct Rect
2918-
{
2919-
int Pitch;
2920-
void* pBits;
2921-
} lrect;
2922-
2923-
lrect.pBits = surfaceCopy->Lock(&lrect.Pitch);
2924-
if (lrect.pBits == NULL)
2925-
{
2926-
surfaceCopy->Release_Ref();
2927-
return;
2928-
}
2929-
2930-
unsigned int x,y,index,index2,width,height;
2931-
2932-
width = surfaceDesc.Width;
2933-
height = surfaceDesc.Height;
2934-
2935-
char *image=NEW char[3*width*height];
2936-
#ifdef CAPTURE_TO_TARGA
2937-
//bytes are mixed in targa files, not rgb order.
2938-
for (y=0; y<height; y++)
2939-
{
2940-
for (x=0; x<width; x++)
2941-
{
2942-
// index for image
2943-
index=3*(x+y*width);
2944-
// index for fb
2945-
index2=y*lrect.Pitch+4*x;
2946-
2947-
image[index]=*((char *) lrect.pBits + index2+2);
2948-
image[index+1]=*((char *) lrect.pBits + index2+1);
2949-
image[index+2]=*((char *) lrect.pBits + index2+0);
2950-
}
2951-
}
2952-
2953-
surfaceCopy->Unlock();
2954-
surfaceCopy->Release_Ref();
2955-
surfaceCopy = NULL;
2956-
2957-
Targa targ;
2958-
memset(&targ.Header,0,sizeof(targ.Header));
2959-
targ.Header.Width=width;
2960-
targ.Header.Height=height;
2961-
targ.Header.PixelDepth=24;
2962-
targ.Header.ImageType=TGA_TRUECOLOR;
2963-
targ.SetImage(image);
2964-
targ.YFlip();
2965-
2966-
targ.Save(pathname,TGAF_IMAGE,false);
2967-
#else //capturing to bmp file
2968-
//bmp is same byte order
2969-
for (y=0; y<height; y++)
2970-
{
2971-
for (x=0; x<width; x++)
2972-
{
2973-
// index for image
2974-
index=3*(x+y*width);
2975-
// index for fb
2976-
index2=y*lrect.Pitch+4*x;
2977-
2978-
image[index]=*((char *) lrect.pBits + index2+0);
2979-
image[index+1]=*((char *) lrect.pBits + index2+1);
2980-
image[index+2]=*((char *) lrect.pBits + index2+2);
2981-
}
2982-
}
2983-
2984-
surfaceCopy->Unlock();
2985-
surfaceCopy->Release_Ref();
2986-
surfaceCopy = NULL;
2987-
2988-
//Flip the image
2989-
char *ptr,*ptr1;
2990-
char v,v1;
2991-
2992-
for (y = 0; y < (height >> 1); y++)
2993-
{
2994-
/* Compute address of lines to exchange. */
2995-
ptr = (image + ((width * y) * 3));
2996-
ptr1 = (image + ((width * (height - 1)) * 3));
2997-
ptr1 -= ((width * y) * 3);
2998-
2999-
/* Exchange all the pixels on this scan line. */
3000-
for (x = 0; x < (width * 3); x++)
3001-
{
3002-
v = *ptr;
3003-
v1 = *ptr1;
3004-
*ptr = v1;
3005-
*ptr1 = v;
3006-
ptr++;
3007-
ptr1++;
3008-
}
3009-
}
3010-
CreateBMPFile(pathname, image, width, height);
3011-
#endif
3012-
3013-
delete [] image;
3014-
3015-
UnicodeString ufileName;
3016-
ufileName.translate(leafname);
3017-
TheInGameUI->message(TheGameText->fetch("GUI:ScreenCapture"), ufileName.str());
3018-
}
3019-
30202882
void W3DDisplay::takeScreenShotCompressed(void)
30212883
{
30222884
W3D_TakeCompressedScreenshot(SCREENSHOT_JPEG, 80);

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,144 +2998,6 @@ static void CreateBMPFile(LPTSTR pszFile, char *image, Int width, Int height)
29982998
LocalFree( (HLOCAL) pbmi);
29992999
}
30003000

3001-
///Save Screen Capture to a file
3002-
void W3DDisplay::takeScreenShot(void)
3003-
{
3004-
char leafname[256];
3005-
char pathname[1024];
3006-
3007-
static int frame_number = 1;
3008-
3009-
Bool done = false;
3010-
while (!done) {
3011-
#ifdef CAPTURE_TO_TARGA
3012-
sprintf( leafname, "%s%.3d.tga", "sshot", frame_number++);
3013-
#else
3014-
sprintf( leafname, "%s%.3d.bmp", "sshot", frame_number++);
3015-
#endif
3016-
strlcpy(pathname, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(pathname));
3017-
strlcat(pathname, leafname, ARRAY_SIZE(pathname));
3018-
if (_access( pathname, 0 ) == -1)
3019-
done = true;
3020-
}
3021-
3022-
// TheSuperHackers @bugfix xezon 21/05/2025 Get the back buffer and create a copy of the surface.
3023-
// Originally this code took the front buffer and tried to lock it. This does not work when the
3024-
// render view clips outside the desktop boundaries. It crashed the game.
3025-
SurfaceClass* surface = DX8Wrapper::_Get_DX8_Back_Buffer();
3026-
3027-
SurfaceClass::SurfaceDescription surfaceDesc;
3028-
surface->Get_Description(surfaceDesc);
3029-
3030-
SurfaceClass* surfaceCopy = NEW_REF(SurfaceClass, (DX8Wrapper::_Create_DX8_Surface(surfaceDesc.Width, surfaceDesc.Height, surfaceDesc.Format)));
3031-
DX8Wrapper::_Copy_DX8_Rects(surface->Peek_D3D_Surface(), NULL, 0, surfaceCopy->Peek_D3D_Surface(), NULL);
3032-
3033-
surface->Release_Ref();
3034-
surface = NULL;
3035-
3036-
struct Rect
3037-
{
3038-
int Pitch;
3039-
void* pBits;
3040-
} lrect;
3041-
3042-
lrect.pBits = surfaceCopy->Lock(&lrect.Pitch);
3043-
if (lrect.pBits == NULL)
3044-
{
3045-
surfaceCopy->Release_Ref();
3046-
return;
3047-
}
3048-
3049-
unsigned int x,y,index,index2,width,height;
3050-
3051-
width = surfaceDesc.Width;
3052-
height = surfaceDesc.Height;
3053-
3054-
char *image=NEW char[3*width*height];
3055-
#ifdef CAPTURE_TO_TARGA
3056-
//bytes are mixed in targa files, not rgb order.
3057-
for (y=0; y<height; y++)
3058-
{
3059-
for (x=0; x<width; x++)
3060-
{
3061-
// index for image
3062-
index=3*(x+y*width);
3063-
// index for fb
3064-
index2=y*lrect.Pitch+4*x;
3065-
3066-
image[index]=*((char *) lrect.pBits + index2+2);
3067-
image[index+1]=*((char *) lrect.pBits + index2+1);
3068-
image[index+2]=*((char *) lrect.pBits + index2+0);
3069-
}
3070-
}
3071-
3072-
surfaceCopy->Unlock();
3073-
surfaceCopy->Release_Ref();
3074-
surfaceCopy = NULL;
3075-
3076-
Targa targ;
3077-
memset(&targ.Header,0,sizeof(targ.Header));
3078-
targ.Header.Width=width;
3079-
targ.Header.Height=height;
3080-
targ.Header.PixelDepth=24;
3081-
targ.Header.ImageType=TGA_TRUECOLOR;
3082-
targ.SetImage(image);
3083-
targ.YFlip();
3084-
3085-
targ.Save(pathname,TGAF_IMAGE,false);
3086-
#else //capturing to bmp file
3087-
//bmp is same byte order
3088-
for (y=0; y<height; y++)
3089-
{
3090-
for (x=0; x<width; x++)
3091-
{
3092-
// index for image
3093-
index=3*(x+y*width);
3094-
// index for fb
3095-
index2=y*lrect.Pitch+4*x;
3096-
3097-
image[index]=*((char *) lrect.pBits + index2+0);
3098-
image[index+1]=*((char *) lrect.pBits + index2+1);
3099-
image[index+2]=*((char *) lrect.pBits + index2+2);
3100-
}
3101-
}
3102-
3103-
surfaceCopy->Unlock();
3104-
surfaceCopy->Release_Ref();
3105-
surfaceCopy = NULL;
3106-
3107-
//Flip the image
3108-
char *ptr,*ptr1;
3109-
char v,v1;
3110-
3111-
for (y = 0; y < (height >> 1); y++)
3112-
{
3113-
/* Compute address of lines to exchange. */
3114-
ptr = (image + ((width * y) * 3));
3115-
ptr1 = (image + ((width * (height - 1)) * 3));
3116-
ptr1 -= ((width * y) * 3);
3117-
3118-
/* Exchange all the pixels on this scan line. */
3119-
for (x = 0; x < (width * 3); x++)
3120-
{
3121-
v = *ptr;
3122-
v1 = *ptr1;
3123-
*ptr = v1;
3124-
*ptr1 = v;
3125-
ptr++;
3126-
ptr1++;
3127-
}
3128-
}
3129-
CreateBMPFile(pathname, image, width, height);
3130-
#endif
3131-
3132-
delete [] image;
3133-
3134-
UnicodeString ufileName;
3135-
ufileName.translate(leafname);
3136-
TheInGameUI->message(TheGameText->fetch("GUI:ScreenCapture"), ufileName.str());
3137-
}
3138-
31393001
void W3DDisplay::takeScreenShotCompressed(void)
31403002
{
31413003
W3D_TakeCompressedScreenshot(SCREENSHOT_JPEG, 80);

0 commit comments

Comments
 (0)