Revision: 10346 https://osdn.net/projects/ttssh2/scm/svn/commits/10346 Author: zmatsuo Date: 2022-11-06 01:52:27 +0900 (Sun, 06 Nov 2022) Log Message: ----------- 画像ファイルの読み込みに LoadImage() APIも使用するようにした - Windows Vista 以降のとき - OLEを利用したjpeg読み込み(GetBitmapHandle())でもbmpは読み込める - LoadImage() だけで読み込めるファイル形式が存在するかもしれない - Windows 10のとき、どちらも高さがマイナスのbmpの読み込みに失敗する Modified Paths: -------------- trunk/teraterm/teraterm/vtdisp.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtdisp.c =================================================================== --- trunk/teraterm/teraterm/vtdisp.c 2022-11-02 13:43:19 UTC (rev 10345) +++ trunk/teraterm/teraterm/vtdisp.c 2022-11-05 16:52:27 UTC (rev 10346) @@ -380,15 +380,13 @@ return TRUE; } -static BOOL LoadWithSPI(const char *src, const wchar_t *spi_path, const char *out) +static BOOL LoadWithSPI(const wchar_t *src, const wchar_t *spi_path, const char *out) { HANDLE hbmi; HANDLE hbuf; BOOL r; - wchar_t *srcW = ToWcharA(src); - r = SusieLoadPicture(srcW, spi_path, &hbmi, &hbuf); - free(srcW); + r = SusieLoadPicture(src, spi_path, &hbmi, &hbuf); if (r == FALSE) { return FALSE; } @@ -438,37 +436,47 @@ // \x89摜\x93ǂݍ\x9E\x82݊W static void BGPreloadPicture(BGSrc *src) { - HBITMAP hbm; - char *load_file = src->file; - const wchar_t *spi_path = ts.EtermLookfeel.BGSPIPathW; + HBITMAP hbm = NULL; + wchar_t *load_file = ToWcharA(src->file); + const wchar_t *spi_path = ts.EtermLookfeel.BGSPIPathW; - if (LoadWithSPI(src->file, spi_path, src->fileTmp) == TRUE) { - load_file = src->fileTmp; - } + // 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 - if (IsLoadImageOnlyEnabled()) { - //\x89摜\x82\xF0\x83r\x83b\x83g\x83}\x83b\x83v\x82Ƃ\xB5\x82ēǂݍ\x9E\x82\xDD - hbm = LoadImage(0,load_file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); + // LoadImageA() API \x82\xC5 HBITMAP \x82ɕϊ\xB7\x82\xB7\x82\xE9 + hbm = LoadImageA(0,src->fileTmp,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); + } - } else { - // Susie plugin\x82œǂݍ\x9E\x82߂Ȃ\xA2JPEG\x83t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB5\x82\xBD\x8Fꍇ\x81A - // OLE \x82𗘗p\x82\xB5\x82ēǂށB - hbm = GetBitmapHandle(load_file); + 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); + } - } + 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 + hbm = LoadImageW(0,load_file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); + } - if(hbm) - { - BITMAP bm; + if(hbm) { + BITMAP bm; - GetObject(hbm,sizeof(bm),&bm); + GetObject(hbm,sizeof(bm),&bm); - src->hdc = CreateBitmapDC(hbm); - src->width = bm.bmWidth; - src->height = bm.bmHeight; - }else{ - src->type = BG_COLOR; - } + src->hdc = CreateBitmapDC(hbm); + src->width = bm.bmWidth; + src->height = bm.bmHeight; + }else{ + src->type = BG_COLOR; + } + + free(load_file); } static void BGGetWallpaperInfo(WallpaperInfo *wi) @@ -528,9 +536,10 @@ // .bmp\x88ȊO\x82̉摜\x83t\x83@\x83C\x83\x8B\x82\xF0\x93ǂށB // \x95ǎ\x86\x82\xAA .bmp \x88ȊO\x82̃t\x83@\x83C\x83\x8B\x82ɂȂ\xC1\x82Ă\xA2\x82\xBD\x8Fꍇ\x82ւ̑Ώ\x88\x81B -// (2011.8.3 yutaka) -// cf. http://www.geocities.jp/ccfjd821/purogu/wpe-ji9.html // \x82\xB1\x82̊\x94\x82\xCD Windows 2000 \x96\xA2\x96\x9E\x82̏ꍇ\x82ɂ͌Ă\xF1\x82ł͂\xA2\x82\xAF\x82Ȃ\xA2 +// TODO: +// IsLoadImageOnlyEnabled() \x82\xCD Vista \x96\xA2\x96\x9E\x82ƂȂ\xC1\x82Ă\xA2\x82\xE9 +// static HBITMAP GetBitmapHandle(const char *File) { OLE_HANDLE hOle = 0;