Skip to content

Commit 0dd496c

Browse files
committed
Remove old BMP screenshot code
1 parent 1126357 commit 0dd496c

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
@@ -2878,144 +2878,6 @@ static void CreateBMPFile(LPTSTR pszFile, char *image, Int width, Int height)
28782878
LocalFree( (HLOCAL) pbmi);
28792879
}
28802880

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

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

0 commit comments

Comments
 (0)