-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding initial PNG/GIF/BMP texture support.
- Loading branch information
1 parent
a2388f6
commit 5a85998
Showing
7 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "stdafx.h" | ||
#include <algorithm> | ||
#include <Shlwapi.h> | ||
#include <GdiPlus.h> | ||
#include "TextConv.hpp" | ||
#include "FileReplacement.h" | ||
#include "FileSystem.h" | ||
#include "Textures.h" | ||
#include "SonicRModLoader.h" | ||
|
||
using std::string; | ||
using namespace Gdiplus; | ||
|
||
const char *extensions[] = { ".png", ".gif", ".bmp" }; | ||
|
||
signed int __cdecl D3D_ReadTPageRGB_r(const char *FilePath, char *Buffer, int BytesPerChannel) | ||
{ | ||
string fp = FilePath; | ||
for (size_t i = 0; i < LengthOfArray(extensions); i++) | ||
{ | ||
ReplaceFileExtension(fp, extensions[i]); | ||
string f2 = fileMap.replaceFile(fp.c_str()); | ||
if (FileExists(f2)) | ||
{ | ||
Bitmap *bmp = Bitmap::FromFile(MBStoUTF16(f2, CP_ACP).c_str()); | ||
Rect rect(0, 0, bmp->GetWidth(), bmp->GetHeight()); | ||
BitmapData bmpd; | ||
bmp->LockBits(&rect, ImageLockModeRead, PixelFormat24bppRGB, &bmpd); | ||
memcpy(Buffer, bmpd.Scan0, abs(bmpd.Stride) * bmpd.Height); | ||
bmp->UnlockBits(&bmpd); | ||
delete bmp; | ||
for (int p = 0; p < BytesPerChannel; p++) | ||
std::swap(Buffer[p * 3], Buffer[p * 3 + 2]); | ||
return 1; | ||
} | ||
} | ||
return D3D_ReadTPageRGB(FilePath, Buffer, BytesPerChannel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
signed int D3D_ReadTPageRGB_r(const char * FilePath, char * Buffer, int BytesPerChannel); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters