Skip to content

Commit 1c23940

Browse files
committed
Remove old BMP screenshot code
1 parent a7a4b4e commit 1c23940

File tree

2 files changed

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

2 files changed

+0
-272
lines changed

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

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,142 +2886,6 @@ static void CreateBMPFile(LPTSTR pszFile, char *image, Int width, Int height)
28862886
}
28872887

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

30262890
void W3DDisplay::takeScreenShotCompressed(void)
30272891
{

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

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,142 +3005,6 @@ static void CreateBMPFile(LPTSTR pszFile, char *image, Int width, Int height)
30053005
}
30063006

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

31453009
void W3DDisplay::takeScreenShotCompressed(void)
31463010
{

0 commit comments

Comments
 (0)