From e95a36b778ea76ddd87e4ff82087fe34670e96b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Thu, 2 May 2024 19:42:10 +0900 Subject: [PATCH] =?utf8?q?=E3=82=B5=E3=82=A4=E3=82=BA=E5=A4=89=E6=9B=B4?= =?utf8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + main.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) 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) -- 2.43.0