<ClCompile Include="..\..\src\cmd-action\cmd-travel.cpp" />\r
<ClCompile Include="..\..\src\cmd-action\cmd-tunnel.cpp" />\r
<ClCompile Include="..\..\src\action\movement-execution.cpp" />\r
+ <ClCompile Include="..\..\src\main-win\read-graphics.cpp" />\r
<ClCompile Include="..\..\src\store\cmd-store.cpp" />\r
<ClCompile Include="..\..\src\cmd-io\cmd-floor.cpp" />\r
<ClCompile Include="..\..\src\cmd-io\cmd-lore.cpp" />\r
<ClInclude Include="..\..\src\cmd-action\cmd-travel.h" />\r
<ClInclude Include="..\..\src\cmd-action\cmd-tunnel.h" />\r
<ClInclude Include="..\..\src\action\movement-execution.h" />\r
+ <ClInclude Include="..\..\src\main-win\read-graphics.h" />\r
+ <ClInclude Include="..\..\src\main-win\tile-info.h" />\r
<ClInclude Include="..\..\src\store\cmd-store.h" />\r
<ClInclude Include="..\..\src\cmd-io\cmd-floor.h" />\r
<ClInclude Include="..\..\src\cmd-io\cmd-lore.h" />\r
<ClCompile Include="..\..\src\mutation\mutation-calculator.cpp" />\r
<ClCompile Include="..\..\src\object\object-info.cpp" />\r
<ClCompile Include="..\..\src\racial\racial-switcher.cpp" />\r
- <ClCompile Include="..\..\src\term\readdib.cpp" />\r
<ClCompile Include="..\..\src\realm\realm-arcane.cpp" />\r
<ClCompile Include="..\..\src\realm\realm-chaos.cpp" />\r
<ClCompile Include="..\..\src\realm\realm-hex.cpp" />\r
<ClInclude Include="..\..\src\player\player-status.h" />\r
<ClInclude Include="..\..\src\dungeon\quest.h" />\r
<ClInclude Include="..\..\src\racial\racial-switcher.h" />\r
- <ClInclude Include="..\..\src\term\readdib.h" />\r
<ClInclude Include="..\..\src\realm\realm-arcane.h" />\r
<ClInclude Include="..\..\src\realm\realm-chaos.h" />\r
<ClInclude Include="..\..\src\realm\realm-craft.h" />\r
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props'))" />\r
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />\r
</Target>\r
-</Project>\r
+</Project>
\ No newline at end of file
<ClCompile Include="..\..\src\birth\history.cpp">\r
<Filter>birth</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\src\term\readdib.cpp">\r
- <Filter>term</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\src\object\warning.cpp">\r
<Filter>object</Filter>\r
</ClCompile>\r
<ClCompile Include="..\..\src\main\scene-table-monster.cpp">\r
<Filter>main</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\src\main-win\read-graphics.cpp">\r
+ <Filter>main-win</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="..\..\src\combat\shoot.h">\r
<ClInclude Include="..\..\src\player\patron.h">\r
<Filter>player</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\..\src\term\readdib.h">\r
- <Filter>term</Filter>\r
- </ClInclude>\r
<ClInclude Include="..\..\src\object\warning.h">\r
<Filter>object</Filter>\r
</ClInclude>\r
<ClInclude Include="..\..\src\store\store-key-processor.h">\r
<Filter>store</Filter>\r
</ClInclude>\r
+ <ClInclude Include="..\..\src\main-win\read-graphics.h">\r
+ <Filter>main-win</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\..\src\main-win\tile-info.h">\r
+ <Filter>main-win</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<None Include="..\..\src\wall.bmp" />\r
<ItemGroup>\r
<ResourceCompile Include="..\..\src\angband.rc" />\r
</ItemGroup>\r
-</Project>\r
+</Project>
\ No newline at end of file
main-win/main-win-sound.cpp main-win/main-win-sound.h \
main-win/main-win-tokenizer.cpp main-win/main-win-tokenizer.h \
main-win/main-win-windows.h \
- term/readdib.cpp term/readdib.h wall.bmp \
+ main-win/read-graphics.cpp main-win/read-graphics.h \
+ main-win/tile-info.h \
+ wall.bmp \
stdafx.cpp stdafx.h
EXTRA_DIST = \
#include "main-win/main-win-menuitem.h"
#include "main-win/main-win-music.h"
#include "main-win/main-win-sound.h"
+#include "main-win/read-graphics.h"
+#include "main-win/tile-info.h"
#include "main/angband-initializer.h"
#include "main/sound-of-music.h"
#include "monster-floor/monster-lite.h"
#include <direct.h>
/*
- * Include the support for loading bitmaps
- */
-#include "term/readdib.h"
-
-/*
* Available graphic modes
*/
-#define GRAPHICS_NONE 0
-#define GRAPHICS_ORIGINAL 1
-#define GRAPHICS_ADAM_BOLT 2
-#define GRAPHICS_HENGBAND 3
+enum graphics_mode {
+ GRAPHICS_NONE = 0,
+ GRAPHICS_ORIGINAL = 1,
+ GRAPHICS_ADAM_BOLT = 2,
+ GRAPHICS_HENGBAND = 3,
+};
/*!
* @struct term_data
*/
static HICON hIcon;
-/*
- * A palette
- */
-static HPALETTE hPal;
-
/* bg */
enum class bg_mode {
BG_NONE = 0,
static byte current_graphics_mode = 0;
/*
- * The global bitmap
+ * The global tile
*/
-static DIBINIT infGraph;
+static tile_info infGraph;
/*
- * The global bitmap mask
+ * The global tile mask
*/
-static DIBINIT infMask;
+static tile_info infMask;
/*
* Show sub-windows even when Hengband is not in focus
*/
static bool init_graphics(void)
{
- char buf[1024];
+ char buf[MAIN_WIN_MAX_PATH];
BYTE wid, hgt, twid, thgt, ox, oy;
concptr name;
+ concptr name_mask = NULL;
+
+ infGraph.delete_bitmap();
+ infMask.delete_bitmap();
if (arg_graphics == GRAPHICS_ADAM_BOLT) {
wid = 16;
ox = 0;
oy = 0;
name = "16X16.BMP";
+ name_mask = "mask.bmp";
ANGBAND_GRAF = "new";
} else if (arg_graphics == GRAPHICS_HENGBAND) {
ox = 0;
oy = 0;
name = "32X32.BMP";
+ name_mask = "mask32.bmp";
ANGBAND_GRAF = "ne2";
} else {
}
path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
- if (!ReadDIB(data[0].w, buf, &infGraph)) {
+ infGraph.hBitmap = read_graphic(buf);
+ if (!infGraph.hBitmap) {
plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
return FALSE;
}
infGraph.OffsetX = ox;
infGraph.OffsetY = oy;
- if (arg_graphics == GRAPHICS_ADAM_BOLT) {
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
- if (!ReadDIB(data[0].w, buf, &infMask)) {
- plog_fmt("Cannot read bitmap file '%s'", buf);
- return FALSE;
- }
- }
-
- if (arg_graphics == GRAPHICS_HENGBAND) {
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
- if (!ReadDIB(data[0].w, buf, &infMask)) {
+ if (name_mask) {
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name_mask);
+ infMask.hBitmap = read_graphic(buf);
+ if (!infMask.hBitmap) {
plog_fmt("Cannot read bitmap file '%s'", buf);
return FALSE;
}
data[i].w = 0;
}
- if (infGraph.hPalette)
- DeleteObject(infGraph.hPalette);
- if (infGraph.hBitmap)
- DeleteObject(infGraph.hBitmap);
- if (infMask.hPalette)
- DeleteObject(infMask.hPalette);
- if (infMask.hBitmap)
- DeleteObject(infMask.hBitmap);
+ infGraph.delete_bitmap();
+ infMask.delete_bitmap();
DeleteObject(hbrYellow);
finalize_bg();
-
- if (hPal)
- DeleteObject(hPal);
+ finalize_graphics();
UnregisterClass(AppName, hInstance);
if (hIcon)
*/
#include "main-win/main-win-bg.h"
-#include "locale/language-switcher.h"
+#include "main-win/read-graphics.h"
#include "system/h-define.h"
-#include "term/z-form.h"
-
-#pragma warning(push)
-#pragma warning(disable : 4458)
-#include <gdiplus.h>
-#pragma warning(pop)
HBITMAP hBG = NULL;
-bool gdi_plus_started = false;
-ULONG_PTR gdiplusToken;
-
-static void init_gdi_plus()
-{
- if (!gdi_plus_started) {
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
- Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
- gdi_plus_started = true;
- }
-}
void finalize_bg()
{
delete_bg();
- if (gdi_plus_started) {
- Gdiplus::GdiplusShutdown(gdiplusToken);
- }
}
void load_bg_prefs(void)
{
- init_gdi_plus();
-
// TODO 背景の設定読込
}
bool load_bg(char* filename)
{
delete_bg();
+ hBG = read_graphic(filename);
- wchar_t wc[MAIN_WIN_MAX_PATH] = L"";
- mbstowcs(wc, filename, MAIN_WIN_MAX_PATH - 1);
- Gdiplus::Bitmap bitmap(wc);
-
- COLORREF bgcolor = RGB(0x00, 0x00, 0x00);
- Gdiplus::Status status = bitmap.GetHBITMAP(bgcolor, &hBG);
-
- return (status == Gdiplus::Ok);
+ return (hBG != NULL);
}
void draw_bg(HDC hdc, RECT *r)
--- /dev/null
+/*!
+ * @file read-graphics.cpp
+ * @brief Windows版固有実装(イメージファイルの読み込み)
+ */
+
+#include "main-win/read-graphics.h"
+#include "main-win/main-win-define.h"
+
+#pragma warning(push)
+#pragma warning(disable : 4458)
+#include <gdiplus.h>
+#pragma warning(pop)
+
+// Flag set once "GDI+" has been initialized
+bool gdi_plus_started = false;
+// a token for "GDI+"
+ULONG_PTR gdiplusToken;
+
+/*!
+ * @brief Cleans up resources used by graphics
+ */
+static inline void init_graphics()
+{
+ if (!gdi_plus_started) {
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+ gdi_plus_started = true;
+ }
+}
+
+void finalize_graphics()
+{
+ if (gdi_plus_started) {
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+ }
+}
+
+HBITMAP read_graphic(char *filename)
+{
+ HBITMAP result = NULL;
+ init_graphics();
+
+ wchar_t wc[MAIN_WIN_MAX_PATH] = L"";
+ ::mbstowcs(wc, filename, MAIN_WIN_MAX_PATH - 1);
+ Gdiplus::Bitmap bitmap(wc);
+
+ COLORREF bgcolor = RGB(0x00, 0x00, 0x00);
+ bitmap.GetHBITMAP(bgcolor, &result);
+
+ return result;
+}
--- /dev/null
+#pragma once
+/*!
+ * @file read-graphics.h
+ * @brief Windows版固有実装(イメージファイルの読み込み)ヘッダ
+ */
+
+#include <windows.h>
+
+/*!
+ * @brief Cleans up resources used by graphics
+ */
+void finalize_graphics();
+
+/*!
+ * @brief Creates a GDI bitmap from an image file
+ * @details
+ * Supported Image File Formats : BMP, ICON, GIF, JPEG, Exif, PNG, TIFF, WMF, and EMF.
+ * @param filename an image file name
+ * @return bitmap handle
+ */
+HBITMAP read_graphic(char *filename);
--- /dev/null
+/*!
+ * @file tile-info.h
+ * @brief Windows版固有(タイル情報)ヘッダ
+ */
+
+#include <windows.h>
+
+/*!
+ * @struct tile_info
+ * @brief Information about a tile
+ */
+struct tile_info {
+ HANDLE hBitmap = NULL;
+ BYTE CellWidth;
+ BYTE CellHeight;
+ BYTE TileWidth;
+ BYTE TileHeight;
+ INT OffsetX;
+ INT OffsetY;
+
+ void delete_bitmap() {
+ if (hBitmap) {
+ DeleteObject(hBitmap);
+ hBitmap = NULL;
+ }
+ }
+};
+++ /dev/null
-/*!
- * @file readdib.c
- * @brief Windows用ビットマップファイル読み込み処理パッケージ /
- * This package provides a routine to read a DIB file and set up the device dependent version of the image.
- * @date 2014/08/08
- * @author
- * This file has been modified for use with "Angband 2.8.2"
- *
- * COPYRIGHT:
- *
- * (C) Copyright Microsoft Corp. 1993. All rights reserved.
- *
- * You have a royalty-free right to use, modify, reproduce and
- * distribute the Sample Files (and/or any modified version) in
- * any way you find useful, provided that you agree that
- * Microsoft has no warranty obligations or liability for any
- * Sample Application Files which are modified.
- * @details
- * mind.cとあるが実際には超能力者、練気術師、狂戦士、鏡使い、忍者までの
- * 特殊技能を揃えて実装している。
- */
-
-#include <windows.h>
-
-#include "term/readdib.h"
-
-/*
- * Needed for lcc-win32
- */
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-/*!
- * 一度にファイルから読み込むデータ量 / Number of bytes to be read during each read operation
- */
-#define MAXREAD 32768
-
-void global_free(DIBINIT *pInfo, INT_PTR *fh, BOOL unlock_needed);
-
-/*!
- * @brief 32KBのデータ読み取りを繰り返すことで、64KB以上のデータを一度に読み取るサブルーチン
- * Private routine to read more than 64K at a time Reads data in steps of 32k till all the data has been read.
- * @param fh ファイルヘッダ
- * @param pv 読み取りポインタ
- * @param ul 読み込むバイト数
- * @return
- * 取得できたデータ量をバイトで返す。0ならば何らかのエラー。
- * Returns number of bytes requested, or zero if something went wrong.
- * @todo コードが古すぎる。何とかしたい
- */
-static DWORD PASCAL lread(int fh, void *pv, DWORD ul)
-{
- DWORD ulT = ul;
- BYTE *hp = static_cast<BYTE*>(pv);
-
- while (ul > (DWORD)MAXREAD)
- {
- if (_lread(fh, (LPSTR)hp, (WORD)MAXREAD) != MAXREAD)
- return 0;
- ul -= MAXREAD;
- hp += MAXREAD;
- }
- if (_lread(fh, (LPSTR)hp, (WORD)ul) != ul)
- return 0;
- return ulT;
-}
-
-
-/*!
- * @brief BITMAPINFOHEADERを取得してカラーテーブルを基本としたパレットを作成する。
- * Given a BITMAPINFOHEADER, create a palette based on the color table.
- * @param lpInfo BITMAPINFOHEADERのポインタ
- * @return
- * パレットの参照を返す。NULLならばエラー。
- * Returns the handle of a palette, or zero if something went wrong.
- */
-static HPALETTE PASCAL MakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
-{
- PLOGPALETTE npPal;
- RGBQUAD *lpRGB;
- HPALETTE hLogPal;
- WORD i;
-
- /*
- * since biClrUsed field was filled during the loading of the DIB,
- * we know it contains the number of colors in the color table.
- */
- if (lpInfo->biClrUsed)
- {
- npPal = (PLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
- (WORD)lpInfo->biClrUsed * sizeof(PALETTEENTRY));
- if (!npPal)
- return(FALSE);
-
- npPal->palVersion = 0x300;
- npPal->palNumEntries = (WORD)lpInfo->biClrUsed;
-
- /* get pointer to the color table */
- lpRGB = (RGBQUAD*)((LPSTR)lpInfo + lpInfo->biSize);
-
- /* copy colors from the color table to the LogPalette structure */
- for (i = 0; i < (WORD)lpInfo->biClrUsed; i++, lpRGB++)
- {
- npPal->palPalEntry[i].peRed = lpRGB->rgbRed;
- npPal->palPalEntry[i].peGreen = lpRGB->rgbGreen;
- npPal->palPalEntry[i].peBlue = lpRGB->rgbBlue;
- npPal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
- }
-
- hLogPal = CreatePalette((LPLOGPALETTE)npPal);
- LocalFree((HANDLE)npPal);
- return(hLogPal);
- }
-
- /*
- * 24-bit DIB with no color table. return default palette. Another
- * option would be to create a 256 color "rainbow" palette to provide
- * some good color choices.
- */
- else
- {
- return static_cast<HPALETTE>(GetStockObject(DEFAULT_PALETTE));
- }
-}
-
-
-/*!
- * @brief
- * ビットマップファイルを受け取り、画像のデバイス依存の描画のために使われる共通パレットとビットマップを作成する
- * Given a DIB, create a bitmap and corresponding palette to be used for a
- * device-dependent representation of the image.
- * @param hDC デバイスコンテキストハンドル
- * @param hDIB ビットマップ画像ハンドル
- * @param phPal パレット取得ハンドル
- * @param phBitmap ビットマップ取得ハンドル
- * @return
- * 成功したならばTRUEを返す。失敗の場合FALSE。
- * Returns TRUE on success (phPal and phBitmap are filled with appropriate
- * handles. Caller is responsible for freeing objects) and FALSE on failure
- * (unable to create objects, both pointer are invalid).
- */
-static BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, HPALETTE * phPal, HBITMAP * phBitmap)
-{
- LPBITMAPINFOHEADER lpInfo;
- BOOL result = FALSE;
- HBITMAP hBitmap;
- HPALETTE hPalette, hOldPal;
- LPSTR lpBits;
-
- lpInfo = (LPBITMAPINFOHEADER) GlobalLock(hDIB);
- if ((hPalette = MakeDIBPalette(lpInfo)) != 0)
- {
- /* Need to realize palette for converting DIB to bitmap. */
- hOldPal = SelectPalette(hDC, hPalette, TRUE);
- RealizePalette(hDC);
-
- lpBits = ((LPSTR)lpInfo + (WORD)lpInfo->biSize +
- (WORD)lpInfo->biClrUsed * sizeof(RGBQUAD));
- hBitmap = CreateDIBitmap(hDC, lpInfo, CBM_INIT, lpBits,
- (LPBITMAPINFO)lpInfo, DIB_RGB_COLORS);
-
- SelectPalette(hDC, hOldPal, TRUE);
- RealizePalette(hDC);
-
- if (!hBitmap)
- {
- DeleteObject(hPalette);
- }
- else
- {
- *phBitmap = hBitmap;
- *phPal = hPalette;
- result = TRUE;
- }
- }
- return(result);
-}
-
-
-
-/*!
- * @brief
- * ビットマップファイルを読み込み、BITMAPINFO構造体にハンドルを取得する。
- * Reads a DIB from a file, obtains a handle to its BITMAPINFO struct, and
- * loads the DIB. Once the DIB is loaded, the function also creates a bitmap
- * and palette out of the DIB for a device-dependent form.
- * device-dependent representation of the image.
- * @param hWnd ウィンドウハンドル
- * @param lpFileName 読み込むビットマップファイル
- * @param pInfo 取得情報を補完するビットマップ情報構造体ポインタ
- * @return
- * Returns TRUE if the DIB is loaded and the bitmap/palette created, in which
- * case, the DIBINIT structure pointed to by pInfo is filled with the appropriate
- * handles, and FALSE if something went wrong.
- * @details
- * Reads a DIB from a file, obtains a handle to its BITMAPINFO struct, and
- * loads the DIB. Once the DIB is loaded, the function also creates a bitmap
- * and palette out of the DIB for a device-dependent form.
- */
-BOOL ReadDIB(HWND hWnd, LPSTR lpFileName, DIBINIT *pInfo)
-{
- LPBITMAPINFOHEADER lpbi;
- OFSTRUCT of;
- BITMAPFILEHEADER bf;
- WORD nNumColors;
- BOOL result = FALSE;
- char str[128];
- WORD offBits;
- HDC hDC;
- BOOL bCoreHead = FALSE;
-
- /* Open the file and get a handle to it's BITMAPINFO */
- INT_PTR fh = OpenFile(lpFileName, &of, OF_READ);
- if (fh == -1)
- {
- wsprintf(str, "Can't open file '%s'", (LPSTR)lpFileName);
- MessageBox(NULL, str, "Error", MB_ICONSTOP | MB_OK);
- return FALSE;
- }
-
- pInfo->hDIB = GlobalAlloc(GHND, (DWORD)(sizeof(BITMAPINFOHEADER) +
- 256 * sizeof(RGBQUAD)));
-
- if (!pInfo->hDIB)
- return FALSE;
-
- lpbi = (LPBITMAPINFOHEADER)GlobalLock(pInfo->hDIB);
-
- BOOL is_read_error = sizeof(bf) != _lread(fh, (LPSTR)&bf, sizeof(bf));
- is_read_error |= bf.bfType != 0x4d42;
- is_read_error |= sizeof(BITMAPCOREHEADER) != _lread(fh, (LPSTR)lpbi, sizeof(BITMAPCOREHEADER));
- if (is_read_error)
- {
- global_free(pInfo, &fh, TRUE);
- return result;
- }
-
- if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
- {
- lpbi->biSize = sizeof(BITMAPINFOHEADER);
- lpbi->biBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
- lpbi->biPlanes = ((LPBITMAPCOREHEADER)lpbi)->bcPlanes;
- lpbi->biHeight = ((LPBITMAPCOREHEADER)lpbi)->bcHeight;
- lpbi->biWidth = ((LPBITMAPCOREHEADER)lpbi)->bcWidth;
- bCoreHead = TRUE;
- }
- else
- {
- /* get to the start of the header and read INFOHEADER */
- _llseek(fh, sizeof(BITMAPFILEHEADER), SEEK_SET);
- if (sizeof(BITMAPINFOHEADER) != _lread(fh, (LPSTR)lpbi, sizeof(BITMAPINFOHEADER)))
- {
- global_free(pInfo, &fh, TRUE);
- return result;
- }
- }
-
- nNumColors = (WORD)lpbi->biClrUsed;
- if (!nNumColors)
- {
- /* no color table for 24-bit, default size otherwise */
- if (lpbi->biBitCount != 24)
- nNumColors = 1 << lpbi->biBitCount;
- }
-
- /* fill in some default values if they are zero */
- if (lpbi->biClrUsed == 0)
- lpbi->biClrUsed = nNumColors;
-
- if (lpbi->biSizeImage == 0)
- {
- lpbi->biSizeImage = (((((lpbi->biWidth * (DWORD)lpbi->biBitCount) + 31) & ~31) >> 3)
- * lpbi->biHeight);
- }
-
- /* otherwise wouldn't work with 16 color bitmaps -- S.K. */
- else if ((nNumColors == 16) && (lpbi->biSizeImage > bf.bfSize))
- {
- lpbi->biSizeImage /= 2;
- }
-
- /* get a proper-sized buffer for header, color table and bits */
- GlobalUnlock(pInfo->hDIB);
- pInfo->hDIB = GlobalReAlloc(pInfo->hDIB, lpbi->biSize +
- nNumColors * sizeof(RGBQUAD) +
- lpbi->biSizeImage, 0);
-
- /* can't resize buffer for loading */
- if (!pInfo->hDIB)
- {
- global_free(pInfo, &fh, FALSE);
- return result;
- }
-
- lpbi = (LPBITMAPINFOHEADER)GlobalLock(pInfo->hDIB);
-
- /* read the color table */
- if (!bCoreHead)
- {
- _lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBQUAD));
- }
- else
- {
- signed int i;
- RGBQUAD *pQuad;
- RGBTRIPLE *pTriple;
-
- _lread(fh, (LPSTR)(lpbi) + lpbi->biSize, nNumColors * sizeof(RGBTRIPLE));
-
- pQuad = (RGBQUAD*)((LPSTR)lpbi + lpbi->biSize);
- pTriple = (RGBTRIPLE*) pQuad;
- for (i = nNumColors - 1; i >= 0; i--)
- {
- pQuad[i].rgbRed = pTriple[i].rgbtRed;
- pQuad[i].rgbBlue = pTriple[i].rgbtBlue;
- pQuad[i].rgbGreen = pTriple[i].rgbtGreen;
- pQuad[i].rgbReserved = 0;
- }
- }
-
- /* offset to the bits from start of DIB header */
- offBits = (WORD)lpbi->biSize + nNumColors * sizeof(RGBQUAD);
-
- if (bf.bfOffBits != 0L)
- {
- _llseek(fh,bf.bfOffBits,SEEK_SET);
- }
-
- /* Use local version of '_lread()' above */
- if (lpbi->biSizeImage == lread(fh, (LPSTR)lpbi + offBits, lpbi->biSizeImage))
- {
- GlobalUnlock(pInfo->hDIB);
-
- hDC = GetDC(hWnd);
- if (!MakeBitmapAndPalette(hDC, pInfo->hDIB, reinterpret_cast<HPALETTE*>(&pInfo->hPalette),
- reinterpret_cast<HBITMAP*>(&pInfo->hBitmap)))
- {
- ReleaseDC(hWnd,hDC);
- global_free(pInfo, &fh, FALSE);
- return result;
- }
- else
- {
- ReleaseDC(hWnd,hDC);
- result = TRUE;
- }
- }
- else
- {
- GlobalUnlock(pInfo->hDIB);
- GlobalFree(pInfo->hDIB);
- }
-
- _lclose(fh);
- return result;
-}
-
-
-void global_free(DIBINIT *pInfo, INT_PTR *fh, BOOL unlock_needed)
-{
- if (unlock_needed)
- {
- GlobalUnlock(pInfo->hDIB);
- }
-
- GlobalFree(pInfo->hDIB);
- _lclose(*fh);
-}
+++ /dev/null
-/*!
- * @file readdib.h
- * @brief ビットマップファイル読み取り処理のヘッダファイル
- * This package provides a routine to read a DIB file and set up the device dependent version of the image.
- * @date 2014/08/08
- * @author
- * Copyright 1991 Microsoft Corporation. All rights reserved.
- * @details
- * This file has been modified for use with "Angband 2.8.2"
- */
-
-/*!
- * @struct DIBINIT
- * @brief ビットマップファイル情報構造体 / Information about a bitmap
- */
-typedef struct {
- HANDLE hDIB;
- HANDLE hBitmap;
- HANDLE hPalette;
- BYTE CellWidth;
- BYTE CellHeight;
- BYTE TileWidth;
- BYTE TileHeight;
- INT OffsetX;
- INT OffsetY;
-} DIBINIT;
-
-/* Read a DIB from a file */
-BOOL ReadDIB(HWND, LPSTR, DIBINIT *);