mirror of
https://github.com/AppleWin/AppleWin.git
synced 2025-02-05 17:30:45 +00:00
Correct BMP creation on Linux (PR #1014)
Enable BMP Header packing on all compilers. Add virtual function to FrameBase to select where to save screenshots.
This commit is contained in:
parent
a243efc74b
commit
d63e406573
@ -121,9 +121,9 @@ void FrameBase::Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotTy
|
||||
void FrameBase::Util_MakeScreenShotFileName(TCHAR* pFinalFileName_, DWORD chars)
|
||||
{
|
||||
const std::string sPrefixScreenShotFileName = "AppleWin_ScreenShot";
|
||||
// TODO: g_sScreenshotDir
|
||||
const std::string pPrefixFileName = !g_pLastDiskImageName.empty() ? g_pLastDiskImageName : sPrefixScreenShotFileName;
|
||||
StringCbPrintf(pFinalFileName_, chars, TEXT("%s_%09d.bmp"), pPrefixFileName.c_str(), g_nLastScreenShot);
|
||||
const std::string folder = Video_GetScreenShotFolder();
|
||||
StringCbPrintf(pFinalFileName_, chars, TEXT("%s%s_%09d.bmp"), folder.c_str(), pPrefixFileName.c_str(), g_nLastScreenShot);
|
||||
}
|
||||
|
||||
// Returns TRUE if file exists, else FALSE
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame);
|
||||
void Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename);
|
||||
|
||||
virtual std::string Video_GetScreenShotFolder() = 0;
|
||||
void Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotType);
|
||||
void Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotType, const TCHAR* pScreenShotFileName);
|
||||
void SetDisplayPrintScreenFileName(bool state) { g_bDisplayPrintScreenFileName = state; }
|
||||
|
@ -509,7 +509,7 @@ void Video::Video_SetBitmapHeader(WinBmpHeader_t *pBmp, int nWidth, int nHeight,
|
||||
|
||||
void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShotType)
|
||||
{
|
||||
WinBmpHeader_t *pBmp = &g_tBmpHeader;
|
||||
WinBmpHeader_t bmp, *pBmp = &bmp;
|
||||
|
||||
Video_SetBitmapHeader(
|
||||
pBmp,
|
||||
@ -518,8 +518,13 @@ void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot
|
||||
32
|
||||
);
|
||||
|
||||
char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == (14 + 40) ];
|
||||
#define EXPECTED_BMP_HEADER_SIZE (14 + 40)
|
||||
#ifdef _MSC_VER
|
||||
char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == EXPECTED_BMP_HEADER_SIZE];
|
||||
/**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0;
|
||||
#else
|
||||
static_assert(sizeof( WinBmpHeader_t ) == EXPECTED_BMP_HEADER_SIZE, "BadWinBmpHeaderPackingSize");
|
||||
#endif
|
||||
|
||||
// Write Header
|
||||
fwrite( pBmp, sizeof( WinBmpHeader_t ), 1, pFile );
|
||||
@ -575,6 +580,11 @@ void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot
|
||||
pSrc += GetFrameBufferWidth();
|
||||
}
|
||||
}
|
||||
|
||||
// re-write the Header to include the file size (otherwise "file" does not recognise it)
|
||||
pBmp->nSizeFile = ftell(pFile);
|
||||
rewind(pFile);
|
||||
fwrite( pBmp, sizeof( WinBmpHeader_t ), 1, pFile );
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -82,13 +82,9 @@ enum AppleFont_e
|
||||
APPLE_FONT_Y_APPLE_40COL = 512, // ][
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// turn of MSVC struct member padding
|
||||
#pragma pack(push,1)
|
||||
#define PACKED
|
||||
#else
|
||||
#define PACKED // TODO: FIXME: gcc/clang __attribute__
|
||||
#endif
|
||||
|
||||
// turn on struct member padding
|
||||
#pragma pack(push,1)
|
||||
|
||||
// TODO: Replace with WinGDI.h / RGBQUAD
|
||||
struct bgra_t
|
||||
@ -174,10 +170,7 @@ struct WinBmpHeader4_t
|
||||
uint32_t nBlueGamma ; // 0x76 0x04
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
#pragma pack(pop)
|
||||
//
|
||||
|
||||
class Video
|
||||
@ -298,8 +291,6 @@ private:
|
||||
COLORREF g_nMonochromeRGB; // saved to Registry
|
||||
bool m_hasVidHD;
|
||||
|
||||
WinBmpHeader_t g_tBmpHeader;
|
||||
|
||||
static const int kVDisplayableScanLines = 192; // max displayable scanlines
|
||||
|
||||
static const UINT kVideoRomSize8K = kVideoRomSize4K*2;
|
||||
|
@ -620,3 +620,9 @@ BYTE* Win32Frame::GetResource(WORD id, LPCSTR lpType, DWORD dwExpectedSize)
|
||||
|
||||
return pResource;
|
||||
}
|
||||
|
||||
std::string Win32Frame::Video_GetScreenShotFolder()
|
||||
{
|
||||
// save in current folder
|
||||
return "";
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ public:
|
||||
virtual BYTE* GetResource(WORD id, LPCSTR lpType, DWORD expectedSize);
|
||||
virtual void Restart();
|
||||
|
||||
virtual std::string Video_GetScreenShotFolder();
|
||||
|
||||
bool GetFullScreenShowSubunitStatus(void);
|
||||
int GetFullScreenOffsetX(void);
|
||||
int GetFullScreenOffsetY(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user