Fix screenshot offset as well as screenshot aspect ratio, also use PNG instead of BMP thanks to issue 1186.

Fix for opening.bnr containing bad chars where the loop would stop when encountering one (fixes Rogue Leader description, which was using 0x0d and 0x0a)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3899 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
sl1nk3.s 2009-07-28 23:38:49 +00:00
parent c86d2e5129
commit caf152fdd0
10 changed files with 52 additions and 97 deletions

View File

@ -553,10 +553,10 @@ static inline std::string GenerateScreenshotName()
std::string tempname, name;
tempname = FULL_SCREENSHOTS_DIR + GetStartupParameter().GetUniqueID();
name = StringFromFormat("%s-%d.bmp", tempname.c_str(), index);
name = StringFromFormat("%s-%d.png", tempname.c_str(), index);
while(File::Exists(name.c_str()))
name = StringFromFormat("%s-%d.bmp", tempname.c_str(), ++index);
name = StringFromFormat("%s-%d.png", tempname.c_str(), ++index);
return name;
}

View File

@ -330,7 +330,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn,
struct sockaddr_in address;
int Return = accept(S, (struct sockaddr *)&address, &addrlen);
GC_sockaddr_in *addr = (GC_sockaddr_in*)Memory::GetPointer(BufferOut);
addr->sin_family = address.sin_family;
addr->sin_family = (u8)address.sin_family;
addr->sin_addr.s_addr_ = address.sin_addr.s_addr;
addr->sin_port = address.sin_port;
socklen_t *Len = (socklen_t *)Memory::GetPointer(BufferOut + 0x04);

View File

@ -30,14 +30,14 @@
namespace DiscIO
{
bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char* _src)
void IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char* _src)
{
static bool bValidChars[256];
static bool bInitialized = false;
if (!bInitialized)
{
for (int i = 0; i < 256; i++)
for (int i = 0; i < 0x20; i++)
{
bValidChars[i] = false;
}
@ -55,7 +55,6 @@ bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char*
bInitialized = true;
}
bool bResult = true;
char destBuffer[2048] = {0};
char* dest = destBuffer;
const char* src = _src;
@ -69,8 +68,8 @@ bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char*
if (bValidChars[c] == false)
{
bResult = false;
break;
src++;
continue;
}
*dest = c;
@ -79,19 +78,9 @@ bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char*
}
// finalize the string
if (bResult)
{
*dest = 0x00;
}
else
{
dest[0] = ' ';
dest[1] = 0x00;
}
*dest = 0x00;
_rDestination = destBuffer;
return(bResult);
}
bool IBannerLoader::CopyBeUnicodeToString( std::string& _rDestination, const u16* _src, int length )

View File

@ -47,7 +47,7 @@ class IBannerLoader
protected:
bool CopyToStringAndCheck(std::string& _rDestination, const char* _src);
void CopyToStringAndCheck(std::string& _rDestination, const char* _src);
bool CopyBeUnicodeToString(std::string& _rDestination, const u16* _src, int length);
private:

View File

@ -57,7 +57,7 @@ CBannerLoaderGC::~CBannerLoaderGC()
bool
CBannerLoaderGC::IsValid()
{
return(m_IsValid);
return m_IsValid;
}
@ -66,13 +66,13 @@ CBannerLoaderGC::GetBanner(u32* _pBannerImage)
{
if (!IsValid())
{
return(false);
return false;
}
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
decode5A3image(_pBannerImage, pBanner->image, DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT);
return(true);
return true;
}
@ -83,7 +83,7 @@ CBannerLoaderGC::GetName(std::string _rName[])
if (!IsValid())
{
return(false);
return false;
}
// find Banner type
@ -151,12 +151,9 @@ CBannerLoaderGC::GetCompany(std::string& _rCompany)
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
if (!CopyToStringAndCheck(_rCompany, pBanner->comment[0].shortMaker))
{
return(false);
}
CopyToStringAndCheck(_rCompany, pBanner->comment[0].shortMaker);
return(true);
return true;
}
@ -167,7 +164,7 @@ CBannerLoaderGC::GetDescription(std::string* _rDescription)
if (!IsValid())
{
return(false);
return false;
}
// find Banner type

View File

@ -42,6 +42,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoOGL", "Plugins\
ProjectSection(ProjectDependencies) = postProject
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED}
{3E03C179-8251-46E4-81F4-466F114BAC63} = {3E03C179-8251-46E4-81F4-466F114BAC63}
{0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E}
{E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA} = {E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}
{1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE}
@ -447,22 +448,6 @@ Global
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.ActiveCfg = Release|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.Build.0 = Release|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Debug|Win32.ActiveCfg = Debug|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Debug|Win32.Build.0 = Debug|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Debug|x64.ActiveCfg = Debug|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Debug|x64.Build.0 = Debug|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.DebugFast|Win32.Build.0 = DebugFast|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.DebugFast|x64.ActiveCfg = DebugFast|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.DebugFast|x64.Build.0 = DebugFast|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release_JITIL|Win32.ActiveCfg = Release|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release_JITIL|Win32.Build.0 = Release|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release_JITIL|x64.ActiveCfg = Release|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release_JITIL|x64.Build.0 = Release|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release|Win32.ActiveCfg = Release|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release|Win32.Build.0 = Release|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release|x64.ActiveCfg = Release|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release|x64.Build.0 = Release|x64
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|Win32.ActiveCfg = Debug|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|Win32.Build.0 = Debug|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|x64.ActiveCfg = Debug|x64

View File

@ -58,7 +58,7 @@ u16 CMailHandler::ReadDSPMailboxLow()
Update();
return(result);
return result;
}
return 0x00;

View File

@ -320,7 +320,7 @@ HRESULT ScreenShot(const char *File)
RECT rect;
::GetWindowRect(EmuWindow::GetWnd(), &rect);
if (FAILED(D3DXSaveSurfaceToFile(File, D3DXIFF_JPG, surf, NULL, &rect)))
if (FAILED(D3DXSaveSurfaceToFile(File, D3DXIFF_PNG, surf, NULL, &rect)))
{
surf->Release();
return S_FALSE;

View File

@ -1282,18 +1282,10 @@ void Renderer::SetScreenshot(const char *filename)
bool Renderer::SaveRenderTarget(const char *filename, int W, int H, int YOffset)
{
// The height seemed to often be one less than the setting (but sometimes not),
// perhaps the source is the (bpmem.copyTexSrcWH.y + 1) in BPStructs.cpp that I'm guessing
// is there because of how some GL function works. But the buffer we are reading from here
// seems to have the necessary pixels for a complete height so we use the complete height
// from the settings.
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
sscanf(g_Config.iInternalRes, "%dx%d", &W, &H);
u8 *data = (u8 *)malloc(3 * W * H);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, YOffset, W, H, GL_RGB, GL_UNSIGNED_BYTE, data);
glReadPixels(0, Renderer::GetTargetHeight() - H + YOffset, W, H, GL_RGB, GL_UNSIGNED_BYTE, data);
// Show failure message
if (glGetError() != GL_NO_ERROR)
@ -1306,51 +1298,45 @@ bool Renderer::SaveRenderTarget(const char *filename, int W, int H, int YOffset)
FlipImageData(data, W, H);
#if defined(HAVE_WX) && HAVE_WX
//Enable support for PNG file type.
wxImage::AddHandler( new wxPNGHandler );
// Create wxImage
wxImage a(W, H, data);
// ---------------------------------------------------------------------
// To get past the problem of non-4:3 and non-16:9 native resolution pictures (for example
// in RE1 some pictures have non-4:3 resolutions like 640 x 448 and 512 x 448 and such that
// are meant to be rescaled to 4:3, and most Wii games use 640 x 480 even for the 16:9 mode)
// we let the user use the keep aspect ratio functions to control the resulting aspect ratio.
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
// We don't adjust non-native resolutions to avoid blurring the picture.
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
float Ratio = (float)W / (float)(H), TargetRatio;
if ((g_Config.bNativeResolution || g_Config.b2xResolution) && (g_Config.bKeepAR169 || g_Config.bKeepAR43)
&& Ratio != 4.0/3.0 && Ratio != 16.0/9.0)
{
if (g_Config.bKeepAR43)
TargetRatio = 4.0/3.0;
else
TargetRatio = 16.0/9.0;
// Check if the height or width should be changed (we only increase the picture size, not
// the other way around)
if (Ratio < TargetRatio)
{
float fW = (float)H * TargetRatio;
W = (int)fW;
}
else
{
float fH = (float)W * (1 / TargetRatio);
H = (int)fH;
}
a.Rescale(W, H, wxIMAGE_QUALITY_HIGH);
}
// ---------------------------------------------------------------------
// These will contain the final image size
float FloatW = (float)W;
float FloatH = (float)H;
a.SaveFile(wxString::FromAscii(filename), wxBITMAP_TYPE_BMP);
// Handle aspect ratio for the final screenshot to look exactly like what's on screen.
if (g_Config.bKeepAR43 || g_Config.bKeepAR169)
{
float Ratio = (FloatW / FloatH) / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// If ratio > 1 the picture is too wide and we have to limit the width.
if (Ratio > 1)
FloatW /= Ratio;
// ratio == 1 or the image is too high, we have to limit the height.
else
FloatH *= Ratio;
a.Rescale((int)FloatW, (int)FloatH, wxIMAGE_QUALITY_HIGH);
}
a.SaveFile(wxString::FromAscii(filename), wxBITMAP_TYPE_PNG);
bool result = true;
// Show success messages
OSD::AddMessage(StringFromFormat("Saved %i x %i %s\n", W, H, s_sScreenshotName.c_str()).c_str(), 2000);
OSD::AddMessage(StringFromFormat("Saved %i x %i %s\n", (int)FloatW, (int)FloatH, s_sScreenshotName.c_str()).c_str(), 2000);
// Finally kill the wxImage object
a.Destroy();
#else
bool result = SaveTGA(filename, W, H, data);
free(data);
#endif
// Do not forget to release the data...
free(data);
return result;
}

View File

@ -258,10 +258,10 @@ HRESULT InitRumble(HWND hWnd)
// Create the prepared effect
if (FAILED(hr = pRumble[i].g_pDevice->CreateEffect(GUID_ConstantForce, &pRumble[i].eff, &pRumble[i].g_pEffect, NULL)))
return hr;
continue;
if (pRumble[i].g_pEffect == NULL)
return E_FAIL;
continue;
}
}
@ -367,10 +367,8 @@ VOID FreeDirectInput()
for (int i=0; i<4; i++) // Free all pads
{
if (pRumble[i].g_pDevice) {
pRumble[i].g_pEffect->Stop();
if (pRumble[i].g_pDevice)
pRumble[i].g_pDevice->Unacquire();
}
SAFE_RELEASE(pRumble[i].g_pEffect);
SAFE_RELEASE(pRumble[i].g_pDevice);