• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisão7fe8cb9c26c10d275d82ea3e19d618fa230c5e6c (tree)
Hora2016-11-06 21:27:03
AutorDeskull <desull@user...>
CommiterDeskull

Mensagem de Log

壁紙機能をGDI+で拡張 / Extend background function by GDI+.

Mudança Sumário

Diff

--- a/Hengband_vcs2010/Hengband/Hengband.vcxproj
+++ b/Hengband_vcs2010/Hengband/Hengband.vcxproj
@@ -163,7 +163,6 @@
163163 <ClCompile Include="..\..\src\obj_kind.c" />
164164 <ClCompile Include="..\..\src\object1.c" />
165165 <ClCompile Include="..\..\src\object2.c" />
166- <ClCompile Include="..\..\src\png-util.cpp" />
167166 <ClCompile Include="..\..\src\racial.c" />
168167 <ClCompile Include="..\..\src\readdib.c" />
169168 <ClCompile Include="..\..\src\report.c" />
@@ -204,7 +203,6 @@
204203 <ClInclude Include="..\..\src\init.h" />
205204 <ClInclude Include="..\..\src\kajitips.h" />
206205 <ClInclude Include="..\..\src\mindtips.h" />
207- <ClInclude Include="..\..\src\png-util.h" />
208206 <ClInclude Include="..\..\src\readdib.h" />
209207 <ClInclude Include="..\..\src\rooms.h" />
210208 <ClInclude Include="..\..\src\streams.h" />
--- a/src/main-win.c
+++ b/src/main-win.c
@@ -81,8 +81,8 @@
8181 #include <locale.h>
8282 #include "z-term.h"
8383 #include "png-util.h"
84-using namespace Gdiplus;
8584
85+using namespace Gdiplus;
8686
8787 /*
8888 * Extract the "WIN32" flag from the compiler
@@ -502,6 +502,10 @@ static char bg_bitmap_file[1024] = "bg.bmp";
502502
503503 static int use_new_gmode = 0;
504504
505+/* GDI+ image */
506+static Image* gdi_images[100];
507+static Image* background_image;
508+
505509 #ifdef USE_SAVER
506510
507511 /*
@@ -765,6 +769,9 @@ static byte special_key_list[] =
765769 };
766770 #endif
767771
772+bool load_image(Image **image, char *filename);
773+void draw_image(HDC hdc, Image *image, int x, int y);
774+
768775 /* bg */
769776 static void delete_bg(void)
770777 {
@@ -777,36 +784,21 @@ static void delete_bg(void)
777784
778785 static int init_bg(void)
779786 {
780- char * bmfile = bg_bitmap_file;
787+ wchar_t wchar[200];
788+ size_t r;
781789
782790 delete_bg();
783791 if (use_bg == 0) return 0;
784-
785- hBG = (HBITMAP)LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
786- if (!hBG) {
787- plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
792+ mbstowcs_s(&r, wchar, 200, bg_bitmap_file, _TRUNCATE);
793+ background_image = new Image(wchar);
794+
795+ if (!background_image || background_image->GetWidth() <= 0 || background_image->GetHeight() <= 0) {
796+ plog_fmt(_("壁紙用画像 '%s' を読み込めません。", "Can't load the image file '%s'."), bg_bitmap_file);
788797 use_bg = 0;
798+ if(background_image) delete(background_image);
789799 return 0;
790800 }
791-#if 0 /* gomi */
792- HDC wnddc, dcimage, dcbg;
793- HBITMAP bmimage, bmimage_old, bmbg_old;
794- int i, j;
795801
796- delete_bg();
797-
798- wnddc = GetDC(hwnd);
799- dcimage = CreateCompatibleDC(wnddc);
800- dcbg = CreateCompatibleDC(wnddc);
801-
802- bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
803- if (!bmimage) quit("bg.bmpが読みこめない!");
804- bmimage_old = SelectObject(dcimage, bmimage);
805-
806- CreateCompatibleBitmap();
807-
808- ReleaseDC(hwnd, wnddc);
809-#endif
810802 use_bg = 1;
811803 return 1;
812804 }
@@ -815,103 +807,41 @@ static void DrawBG(HDC hdc, RECT *r)
815807 {
816808 HDC hdcSrc;
817809 HBITMAP hOld;
818- BITMAP bm;
819810 int x = r->left, y = r->top;
820811 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
821-
822- if (!use_bg || !hBG)
823- return;
812+ Gdiplus::Rect rec;
813+ if(!background_image) return;
824814
825815 nx = x; ny = y;
826- GetObject(hBG, sizeof(bm), &bm);
827- swid = bm.bmWidth; shgt = bm.bmHeight;
828-
816+ swid = background_image->GetWidth(); shgt = background_image->GetHeight();
817+ if(swid == 0 || shgt == 0)
818+ {
819+ return;
820+ }
821+ Graphics graphics(hdc);
829822 hdcSrc = CreateCompatibleDC(hdc);
830823 hOld = (HBITMAP)SelectObject(hdcSrc, hBG);
831-
824+ Unit srcunit = UnitPixel;
832825 do {
833826 sx = nx % swid;
834827 cwid = MIN(swid - sx, r->right - nx);
835828 do {
836829 sy = ny % shgt;
837830 chgt = MIN(shgt - sy, r->bottom - ny);
838- BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
831+
832+ rec = Gdiplus::Rect(sx, sy, cwid, chgt);
833+ graphics.DrawImage(background_image, rec, nx, ny, cwid, chgt, srcunit);
834+// graphics.DrawImage(background_image, nx, ny, sx, sy, swid, shgt, srcunit);
839835 ny += chgt;
840836 } while (ny < r->bottom);
841837 ny = y;
842838 nx += cwid;
843839 } while (nx < r->right);
844-
840+
845841 SelectObject(hdcSrc, hOld);
846842 DeleteDC(hdcSrc);
847843 }
848844
849-#if 0
850-/*
851- * Hack -- given a pathname, point at the filename
852- */
853-static cptr extract_file_name(cptr s)
854-{
855- cptr p;
856-
857- /* Start at the end */
858- p = s + strlen(s) - 1;
859-
860- /* Back up to divider */
861- while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
862-
863- /* Return file name */
864- return (p+1);
865-}
866-#endif
867-
868-
869-/*
870- * Hack -- given a simple filename, extract the "font size" info
871- *
872- * Return a pointer to a static buffer holding the capitalized base name.
873- */
874-#if 0 /* #ifndef JP */
875-static char *analyze_font(char *path, int *wp, int *hp)
876-{
877- int wid, hgt;
878-
879- char *s, *p;
880-
881- /* Start at the end */
882- p = path + strlen(path) - 1;
883-
884- /* Back up to divider */
885- while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
886-
887- /* Advance to file name */
888- ++p;
889-
890- /* Capitalize */
891- for (s = p; *s; ++s)
892- {
893- /* Capitalize (be paranoid) */
894- if (islower(*s)) *s = toupper(*s);
895- }
896-
897- /* Find first 'X' */
898- s = my_strchr(p, 'X');
899-
900- /* Extract font width */
901- wid = atoi(p);
902-
903- /* Extract height */
904- hgt = s ? atoi(s+1) : 0;
905-
906- /* Save results */
907- (*wp) = wid;
908- (*hp) = hgt;
909-
910- /* Result */
911- return (p);
912-}
913-#endif
914-
915845
916846 /*
917847 * Check for existance of a file
@@ -1053,17 +983,25 @@ static void validate_dir(cptr s, bool vital)
1053983 }
1054984 }
1055985
1056-bool load_image(HWND hwnd, Image *image, char *filename)
986+bool load_image(Image **image, char *filename)
1057987 {
1058988 size_t r;
1059989 char buf[200];
1060990 wchar_t wchar[200];
1061991 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, filename);
1062992 mbstowcs_s(&r, wchar, 200, buf, _TRUNCATE);
1063- image = new Image(wchar);
993+ *image = new Image(wchar);
1064994 return true;
1065995 }
1066996
997+void draw_image(HDC hdc, Image *image, int x, int y)
998+{
999+ if(image == NULL) return;
1000+ Graphics graphics(hdc);
1001+ graphics.DrawImage(image, x, y);
1002+}
1003+
1004+
10671005 /*
10681006 * Get the "size" for a window
10691007 */
@@ -2826,7 +2764,9 @@ static errr Term_wipe_win(int x, int y, int n)
28262764 SelectObject(hdc, td->font_id);
28272765 /* bg */
28282766 if (use_bg)
2767+ {
28292768 DrawBG(hdc, &rc);
2769+ }
28302770 else
28312771 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
28322772 ReleaseDC(td->w, hdc);
@@ -2909,7 +2849,10 @@ static errr Term_text_win(int x, int y, int n, byte a, const char *s)
29092849 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
29102850
29112851 /* bg */
2912- if (use_bg) DrawBG(hdc, &rc);
2852+ if (use_bg)
2853+ {
2854+ DrawBG(hdc, &rc);
2855+ }
29132856
29142857 /* New rectangle */
29152858 rc.left += ((td->tile_wid - td->font_wid) / 2);
@@ -4437,7 +4380,7 @@ static void process_menus(WORD wCmd)
44374380 memset(&ofn, 0, sizeof(ofn));
44384381 ofn.lStructSize = sizeof(ofn);
44394382 ofn.hwndOwner = data[0].w;
4440- ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
4383+ ofn.lpstrFilter = "Image Files (*.bmp, *.png, *.jpg, *.jpeg)\0*.*\0";
44414384 ofn.nFilterIndex = 1;
44424385 ofn.lpstrFile = bg_bitmap_file;
44434386 ofn.nMaxFile = 1023;
--- a/src/png-util.cpp
+++ b/src/png-util.cpp
@@ -0,0 +1,4 @@
1+#include <windows.h>
2+#include <gdiplus.h>
3+using namespace Gdiplus;
4+
--- a/src/png-util.h
+++ b/src/png-util.h
@@ -0,0 +1 @@
1+bool paint_test(HWND hwnd);