[Ttssh2-commit] [4568] Eterm look feel:

svnno****@sourc***** svnno****@sourc*****
2011年 8月 3日 (水) 23:42:03 JST


Revision: 4568
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4568
Author:   yutakapon
Date:     2011-08-03 23:42:03 +0900 (Wed, 03 Aug 2011)

Log Message:
-----------
Eterm look feel:
壁紙が .bmp 形式以外においても、読み込みができるようにした。
ただし、拡大表示(ストレッチブリット)には未対応。

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtdisp.c


-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtdisp.c
===================================================================
--- trunk/teraterm/teraterm/vtdisp.c	2011-08-03 10:24:44 UTC (rev 4567)
+++ trunk/teraterm/teraterm/vtdisp.c	2011-08-03 14:42:03 UTC (rev 4568)
@@ -15,6 +15,7 @@
 #include "vtdisp.h"
 
 #include <locale.h>
+#include<olectl.h>
 
 #define CurWidth 2
 
@@ -636,6 +637,48 @@
   RegCloseKey(hKey);
 }
 
+// .bmpˆÈŠO‚̉摜ƒtƒ@ƒCƒ‹‚ð“ǂށB
+// •ÇŽ†‚ª .bmp ˆÈŠO‚̃tƒ@ƒCƒ‹‚É‚È‚Á‚Ä‚¢‚½ê‡‚ւ̑ΏˆB
+// (2011.8.3 yutaka)
+// cf. http://www.geocities.jp/ccfjd821/purogu/wpe-ji9.html
+static HBITMAP GetBitmapHandle(char *File)
+{  
+	OLE_HANDLE hOle = 0;
+	IStream *iStream=NULL;
+	IPicture *iPicture;
+	HGLOBAL hMem;
+	LPVOID pvData;
+	DWORD nReadByte=0,nFileSize;
+	HANDLE hFile;
+	short type;
+	HBITMAP hBitmap = NULL;
+
+	hFile=CreateFile(File,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
+	nFileSize=GetFileSize(hFile,NULL);
+	hMem=GlobalAlloc(GMEM_MOVEABLE,nFileSize);
+	pvData=GlobalLock(hMem);
+
+	ReadFile(hFile,pvData,nFileSize,&nReadByte,NULL);
+
+	GlobalUnlock(hMem);
+	CloseHandle(hFile);
+
+	CreateStreamOnHGlobal(hMem,TRUE,&iStream);
+
+	OleLoadPicture(iStream,nFileSize,FALSE,&IID_IPicture,(LPVOID*)&iPicture);
+
+	iStream->lpVtbl->Release((IStream *)iPicture);
+
+	iPicture->lpVtbl->get_Type(iPicture,&type);
+	if(type==PICTYPE_BITMAP){
+		iPicture->lpVtbl->get_Handle(iPicture,&hOle);
+	}
+
+	hBitmap=(HBITMAP)hOle;
+
+	return (hBitmap);
+}
+
 void BGPreloadWallpaper(BGSrc *src)
 {
   HBITMAP       hbm;
@@ -645,10 +688,13 @@
 
   //•ÇŽ†‚ð“ǂݍž‚Ý
   //LR_CREATEDIBSECTION ‚ðŽw’è‚·‚é‚Ì‚ªƒRƒc
-  if(wi.pattern == BG_STRETCH)
+  if (wi.pattern == BG_STRETCH) {
     hbm = LoadImage(0,wi.filename,IMAGE_BITMAP,CRTWidth,CRTHeight,LR_LOADFROMFILE | LR_CREATEDIBSECTION);
-  else
-    hbm = LoadImage(0,wi.filename,IMAGE_BITMAP,        0,       0,LR_LOADFROMFILE);
+	// TODO: ‰æ‘œ‚ð‰æ–Ê‚¢‚Á‚Ï‚¢‚ÉŠg‘å‚·‚é‚ɂ́A‚Ç‚¤‚µ‚½‚ç‚æ‚¢‚©H
+  } else {
+    //hbm = LoadImage(0,wi.filename,IMAGE_BITMAP,        0,       0,LR_LOADFROMFILE);
+	hbm = GetBitmapHandle(wi.filename);
+  }
 
   //•ÇŽ†DC‚ðì‚é
   if(hbm)
@@ -661,6 +707,7 @@
     src->width   = bm.bmWidth;
     src->height  = bm.bmHeight;
     src->pattern = wi.pattern;
+
   }else{
     src->hdc = NULL;
   }



Ttssh2-commit メーリングリストの案内