Revision: 10352 https://osdn.net/projects/ttssh2/scm/svn/commits/10352 Author: zmatsuo Date: 2022-11-07 00:35:05 +0900 (Mon, 07 Nov 2022) Log Message: ----------- Susie plugin でロードした画像をオンメモリで処理するよう修正 - 従来は bmp ファイル(テンポラリファイル)へ保存、ロードして HBITMAP に変換していた - テンポラリファイルに関する処理を削除 - テンポラリファイルを使用しなくなったため Modified Paths: -------------- trunk/teraterm/teraterm/vtdisp.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtdisp.c =================================================================== --- trunk/teraterm/teraterm/vtdisp.c 2022-11-06 15:34:56 UTC (rev 10351) +++ trunk/teraterm/teraterm/vtdisp.c 2022-11-06 15:35:05 UTC (rev 10352) @@ -133,7 +133,6 @@ int width; int height; char file[MAX_PATH]; - char fileTmp[MAX_PATH]; }BGSrc; static BGSrc BGDest; @@ -337,6 +336,10 @@ #endif } +/** + * BMP\x95ۑ\xB6\x81A\x83f\x83o\x83O\x82Ɏg\x82\xA4\x82\xA9\x82\xE0\x82\xB5\x82\xEA\x82Ȃ\xA2\x82̂Ŏc\x82\xB5\x82Ă\xA8\x82\xAD + */ +#if 0 static BOOL SaveBitmapFile(const char *nameFile,unsigned char *pbuf,BITMAPINFO *pbmi) { int bmiSize; @@ -383,24 +386,18 @@ return TRUE; } +#endif -static BOOL LoadWithSPI(const wchar_t *src, const wchar_t *spi_path, const char *out) +static HBITMAP CreateBitmapFromBITMAPINFO(const BITMAPINFO *pbmi, const unsigned char *pbuf) { - HANDLE hbmi; - HANDLE hbuf; - BOOL r; + void* pvBits; + HBITMAP hBmp = CreateDIBSection(NULL, pbmi, DIB_RGB_COLORS, &pvBits, NULL, 0x0); - r = SusieLoadPicture(src, spi_path, &hbmi, &hbuf); - if (r == FALSE) { - return FALSE; + if (pbuf != NULL) { + memcpy(pvBits, pbuf, pbmi->bmiHeader.biSizeImage); } - SaveBitmapFile(out, hbuf, hbmi); - - LocalFree(hbmi); - LocalFree(hbuf); - - return TRUE; + return hBmp; } static BOOL WINAPI AlphaBlendWithoutAPI(HDC hdcDest,int dx,int dy,int width,int height,HDC hdcSrc,int sx,int sy,int sw,int sh,BLENDFUNCTION bf) @@ -445,14 +442,18 @@ const wchar_t *spi_path = ts.EtermLookfeel.BGSPIPathW; // Susie plugin \x82œǂݍ\x9E\x82\xDD - if (LoadWithSPI(load_file, spi_path, src->fileTmp) == TRUE) { - // \x93ǂݍ\x9E\x82߂\xBD - // \x93ǂ摜\x82\xCD BMP\x8C`\x8E\xAE\x82\xC5 src->fileTmp \x82ɕۑ\xB6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9 - - // LoadImageA() API \x82\xC5 HBITMAP \x82ɕϊ\xB7\x82\xB7\x82\xE9 - hbm = LoadImageA(0,src->fileTmp,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); + if (hbm == NULL) { + HANDLE hbmi; + HANDLE hbuf; + BOOL r = SusieLoadPicture(load_file, spi_path, &hbmi, &hbuf); + if (r != FALSE) { + hbm = CreateBitmapFromBITMAPINFO(hbmi, hbuf); + LocalFree(hbmi); + LocalFree(hbuf); + } } + // GDI+ \x83\x89\x83C\x83u\x83\x89\x83\x8A\x82\xF0\x8Eg\x82\xC1\x82ēǂݍ\x9E\x82\xDE #if ENABLE_GDIPLUS if (hbm == NULL) { hbm = GDIPLoad(load_file); @@ -459,18 +460,19 @@ } #endif + // OLE \x82𗘗p\x82\xB5\x82ĉ摜(jpeg)\x82\xF0\x93ǂ\xDE + // LoadImage()\x82̂\x96\x89\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x8A\xAB\x82ł͂Ȃ\xA2\x82Ƃ\xAB if (hbm == NULL && !IsLoadImageOnlyEnabled()) { - // OLE \x82𗘗p\x82\xB5\x82\xC4jpeg\x82\xF0\x93ǂ\xDE - // LoadImage()\x82̂\x96\x89\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x8A\xAB\x82ł͂Ȃ\xA2\x82Ƃ\xAB char *load_fileA = ToCharW(load_file); hbm = GetBitmapHandle(load_fileA); free(load_fileA); } + // LoadImageW() API \x82œǂݍ\x9E\x82\xDE if (hbm == NULL) { - // \x89摜\x82\xF0 LoadImageW() API \x82œǂݍ\x9E\x82\xDE - // Windows 10 \x82ł͍\x82\x82\xB3\x82\xAA\x83}\x83C\x83i\x83X\x82\xCCbmp\x83t\x83@\x83C\x83\x8B\x82̓\x8D\x81[\x83h\x82Ɏ\xB8\x94s\x82\xB7\x82\xE9 - // Windows 7 \x82ł͐\xAC\x8C\x{1C2DC2}\xE9 + // LoadImageW() API\x82́A + // Windows 10 \x82̂Ƃ\xAB\x8D\x82\x82\xB3\x82\xAA\x83}\x83C\x83i\x83X\x82\xCCbmp\x83t\x83@\x83C\x83\x8B\x82̓\x8D\x81[\x83h\x82Ɏ\xB8\x94s\x82\xB7\x82\xE9 + // Windows 7 \x82̂Ƃ\xAB\x82͐\xAC\x8C\x{1C2DC2}\xE9 hbm = LoadImageW(0,load_file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); } @@ -1152,11 +1154,6 @@ DeleteBitmapDC(&(BGSrc1.hdc)); DeleteBitmapDC(&(BGSrc2.hdc)); - //\x83e\x83\x93\x83|\x83\x89\x83\x8A\x81[\x83t\x83@\x83C\x83\x8B\x8D폜 - DeleteFile(BGDest.fileTmp); - DeleteFile(BGSrc1.fileTmp); - DeleteFile(BGSrc2.fileTmp); - BGEnable = FALSE; } @@ -1185,16 +1182,6 @@ //\x83\x8A\x83\\x81[\x83X\x89\xF0\x95\xFA BGDestruct(); - //\x83e\x83\x93\x83|\x83\x89\x83\x8A\x81[\x83t\x83@\x83C\x83\x8B\x96\xBC\x82\xAC - { - char tempPath[MAX_PATH]; - ZeroMemory(tempPath, sizeof(tempPath)); - GetTempPathA(MAX_PATH, tempPath); - GetTempFileNameA(tempPath, "ttAK", 0, BGDest.fileTmp); - GetTempFileNameA(tempPath, "ttAK", 0, BGSrc1.fileTmp); - GetTempFileNameA(tempPath, "ttAK", 0, BGSrc2.fileTmp); - } - // AlphaBlend \x82̃A\x83h\x83\x8C\x83X\x82\xF0\x93ǂݍ\x9E\x82\xDD if (ts.EtermLookfeel.BGUseAlphaBlendAPI) { if (pAlphaBlend != NULL)