From: 諏訪子 Date: Thu, 2 May 2024 10:42:10 +0000 (+0900) Subject: サイズ変更の修正 X-Git-Tag: mivfx-0.5.0~11 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=e95a36b778ea76ddd87e4ff82087fe34670e96b9;p=mivfx.git サイズ変更の修正 --- diff --git a/CHANGELOG.md b/CHANGELOG.md index b4de41e..953ed16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * CDNを回避する様に * 画像は大き過ぎるの場合、画面に合うまで小さくにする様に * 「Q」キーを押すと、終了する様に +* サイズ変更の修正 # 0.4.0 * URLから画像ファイルを開ける様に diff --git a/main.c b/main.c index 0030e71..cd5449c 100644 --- a/main.c +++ b/main.c @@ -92,22 +92,23 @@ void windowevent(SDL_Event e) { if (scaledWidth >= (screenWidth-20)) scaledWidth = screenWidth-20; if (scaledHeight >= (screenHeight-20)) scaledHeight = screenHeight-20; - // テキスチャーのれんダーリングサイズの設定 - SDL_Rect renderQuad = { imgWidth, imgHeight, scaledWidth, scaledHeight }; - SDL_RenderCopy(renderer, texture, NULL, &renderQuad); + // テキスチャーのレンダーリングサイズの設定 + renderQuad.x = imgWidth; + renderQuad.y = imgHeight; + renderQuad.w = scaledWidth; + renderQuad.h = scaledHeight; + SDL_SetWindowSize(window, scaledWidth, scaledHeight); + SDL_RenderCopy(renderer, texture, NULL, &renderQuad); } else if (e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_EXPOSED) { SDL_Rect renderQuad = { imgWidth, imgHeight, imgWidth, imgHeight }; SDL_RenderClear(renderer); + renderQuad.w = (windowWidth - 20); + renderQuad.h = (windowHeight - 20); renderQuad.x = (windowWidth - renderQuad.w) / 2; renderQuad.y = (windowHeight - renderQuad.h) / 2; - if (init == 0) { - renderQuad.w = imgWidth; - renderQuad.h = imgHeight; - } - if ( (imgWidth >= (screenWidth - 100)) && imgHeight >= (screenHeight - 100)