2 #include<Multimedia/SDX.h>
3 #include<Multimedia/Screen.h>
40 friend class ImagePack;
43 bool isScreen =
false;
44 bool isAlphaChannel =
false;
53 ImageHandle handle = 0;
57 void RGBACulculate()
const
59 if (Screen::Single().nowBlendMode == BlendMode::NoBlend)
61 SDL_SetTextureBlendMode(handle, (SDL_BlendMode)BlendMode::Alpha);
62 SDL_SetTextureAlphaMod(handle, 255);
64 SDL_SetTextureBlendMode(handle, (SDL_BlendMode)Screen::Single().nowBlendMode);
65 SDL_SetTextureAlphaMod(handle, Screen::Single().blendParam);
68 SDL_SetTextureColorMod
71 Screen::Single().rgba.GetRed(),
72 Screen::Single().rgba.GetGreen(),
73 Screen::Single().rgba.GetBlue()
81 Image(
const char *ファイル名)
86 Image(Image& コピー元,
int X頂点,
int Y頂点,
int 幅,
int 高さ)
88 Copy(コピー元, X頂点, Y頂点, 幅, 高さ);
92 Image(
int 幅 ,
int 高さ ,
bool スクリーン用フラグ ,
bool αチャンネルフラグ =
true,
bool 透過フラグ =
true)
94 Make(幅, 高さ, スクリーン用フラグ, αチャンネルフラグ, 透過フラグ);
98 bool Load(
const char *ファイル名)
101 if (this->handle != NULL_HANDLE) DxLib::DeleteGraph(this->handle);
102 this->handle = DxLib::LoadGraph(ファイル名);
103 this->isTrans =
true;
104 this->isScreen =
false;
106 DxLib::GetGraphSize( this->
GetHandle() , &width , &height );
107 return ( this->handle != -1 );
110 SDL_Surface* temp = IMG_Load(ファイル名);
111 if (temp ==
nullptr)
return false;
113 handle = SDL_CreateTextureFromSurface(Screen::GetHandle(), temp);
120 SDL_FreeSurface(temp);
129 return !DxLib::DeleteGraph(this->handle);
131 if (this->handle !=
nullptr)
133 SDL_DestroyTexture(handle);
142 ImageHandle
Make(
int 幅,
int 高さ,
bool スクリーン用フラグ =
false,
bool αチャンネルフラグ =
true,
bool 透過フラグ =
true)
148 handle = DxLib::MakeScreen(幅, 高さ, αチャンネルフラグ);
150 handle = DxLib::MakeGraph(幅, 高さ);
152 DxLib::GetGraphSize(
GetHandle() , &width , &height );
154 SDL_CreateTexture(Screen::GetHandle(), 0, 0, 幅, 高さ);
161 isScreen = スクリーン用フラグ;
162 isAlphaChannel = αチャンネルフラグ;
168 ImageHandle
Copy(
const Image& 元イメージ,
int X原点,
int Y原点,
int 幅,
int 高さ)
171 this->handle = DxLib::DerivationGraph( X原点, Y原点, 幅, 高さ, 元イメージ.handle);
175 this->handle = 元イメージ.handle;
181 this->isTrans = 元イメージ.isTrans;
182 this->isScreen =
false;
183 this->isAlphaChannel =
false;
195 bool Draw(
int X座標,
int Y座標 ,
bool 反転フラグ =
false)
const
200 return !DxLib::DrawTurnGraph( X座標 , Y座標 , this->
GetHandle() , this->isTrans );
202 return !DxLib::DrawGraph( X座標 , Y座標 , this->
GetHandle() , this->isTrans );
205 SDL_Rect temp = { X座標, Y座標, part.w, part.h };
209 static SDL_Point point = { 0, 0 };
210 return !SDL_RenderCopyEx(Screen::GetHandle(), handle, &part, &temp , 0 , &point , SDL_RendererFlip::SDL_FLIP_HORIZONTAL );
212 return !SDL_RenderCopy(Screen::GetHandle(), handle, &part, &temp );
217 bool ZMask(
int X座標,
int Y座標 , ZMaskType Zマスクタイプ ,
bool 反転フラグ =
false)
const
222 return !DxLib::DrawTurnGraphToZBuffer( X座標 , Y座標 , this->
GetHandle() , (
int)Zマスクタイプ );
225 return !DxLib::DrawGraphToZBuffer(X座標, Y座標, this->
GetHandle(), (
int)Zマスクタイプ);
236 return !DxLib::DrawExtendGraph(X座標A, Y座標A, X座標B, Y座標B, this->
GetHandle(), this->isTrans);
238 SDL_Rect temp = { X座標A, Y座標A, X座標B - X座標A, Y座標B - Y座標A };
240 return !SDL_RenderCopy(Screen::GetHandle(), handle, &part, &temp);
243 bool ZMaskExtend(
int X座標A,
int Y座標A,
int X座標B,
int Y座標B , ZMaskType Zマスクタイプ)
const
246 return !DxLib::DrawExtendGraphToZBuffer(X座標A, Y座標A, X座標B, Y座標B, this->
GetHandle(), (
int)Zマスクタイプ);
253 bool DrawRotate(
int X座標,
int Y座標,
double 拡大率,
double 角度,
bool 反転フラグ =
false)
const
256 return !DxLib::DrawRotaGraph(X座標, Y座標, 拡大率, 角度, this->
GetHandle(), this->isTrans, 反転フラグ);
258 const int wbuf = int(part.w*拡大率);
259 const int hbuf = int(part.h*拡大率);
260 SDL_Rect temp = { X座標 - wbuf/2, Y座標 - hbuf/2, wbuf , hbuf };
261 SDL_Point point = { wbuf / 2, hbuf / 2 };
263 return !SDL_RenderCopyEx(Screen::GetHandle(), handle, &part, &temp, 角度*180 / PAI, &point, SDL_RendererFlip(反転フラグ));
266 bool DrawRotateZMask(
int X座標,
int Y座標,
double 拡大率,
double 角度, ZMaskType Zマスクタイプ,
bool 反転フラグ =
false)
const
269 return !DxLib::DrawRotaGraphToZBuffer(X座標, Y座標, 拡大率, 角度, this->
GetHandle(), (
int)Zマスクタイプ, 反転フラグ);
276 bool DrawRotateAxis(
int X座標,
int Y座標,
int X軸,
int Y軸,
double 拡大率,
double 角度,
bool 反転フラグ =
false)
const
279 return !DxLib::DrawRotaGraph2(X座標, Y座標, X軸, Y軸, 拡大率, 角度, this->
GetHandle(), this->isTrans, 反転フラグ);
281 const int wbuf = int(part.w*拡大率);
282 const int hbuf = int(part.h*拡大率);
283 SDL_Rect temp = { X座標 - wbuf / 2, Y座標 - hbuf / 2, wbuf, hbuf };
284 SDL_Point point = { wbuf / 2, hbuf / 2 };
286 return !SDL_RenderCopyEx(Screen::GetHandle(), handle, &part, &temp, 角度, &point, SDL_RendererFlip(反転フラグ));
289 bool ZMaskRotateAxis(
int X座標,
int Y座標,
int X軸,
int Y軸,
double 拡大率,
double 角度, ZMaskType Zマスクタイプ,
bool 反転フラグ =
false)
const
292 return !DxLib::DrawRotaGraph2ToZBuffer(X座標, Y座標, X軸, Y軸, 拡大率, 角度, this->
GetHandle(), (
int)Zマスクタイプ, 反転フラグ);
299 bool DrawRotateAxis(
int X座標,
int Y座標,
int X軸,
int Y軸,
double 拡大率X,
double 拡大率Y,
double 角度,
bool 反転フラグ =
false)
const
302 return !DxLib::DrawRotaGraph3(X座標, Y座標, X軸, Y軸, 拡大率X, 拡大率Y, 角度, this->
GetHandle(), this->isTrans, 反転フラグ);
304 const int wbuf = int(part.w*拡大率X);
305 const int hbuf = int(part.h*拡大率Y);
306 SDL_Rect temp = { X座標 - wbuf / 2, Y座標 - hbuf / 2, wbuf, hbuf };
307 SDL_Point point = { wbuf / 2, hbuf / 2 };
309 return !SDL_RenderCopyEx(Screen::GetHandle(), handle, &part, &temp, 角度, &point, SDL_RendererFlip(反転フラグ));
312 bool ZMaskRotateAxis(
int X座標,
int Y座標,
int X軸,
int Y軸,
double 拡大率X,
double 拡大率Y,
double 角度, ZMaskType Zマスクタイプ,
bool 反転フラグ =
false)
const
315 return !DxLib::DrawRotaGraph3ToZBuffer(X座標, Y座標, X軸, Y軸, 拡大率X, 拡大率Y, 角度, this->
GetHandle(), (
int)Zマスクタイプ, 反転フラグ);
322 bool DrawModify(
int 頂点aX,
int 頂点aY,
int 頂点bX,
int 頂点bY,
int 頂点cX,
int 頂点cY,
int 頂点dX,
int 頂点dY)
const
325 return !DxLib::DrawModiGraph(頂点aX, 頂点aY, 頂点bX, 頂点bY, 頂点cX, 頂点cY, 頂点dX, 頂点dY, this->
GetHandle(), this->isTrans);
330 bool ZMaskModify(
int 頂点aX,
int 頂点aY,
int 頂点bX,
int 頂点bY,
int 頂点cX,
int 頂点cY,
int 頂点dX,
int 頂点dY, ZMaskType Zマスクタイプ)
const
333 return !DxLib::DrawModiGraphToZBuffer(頂点aX, 頂点aY, 頂点bX, 頂点bY, 頂点cX, 頂点cY, 頂点dX, 頂点dY, this->
GetHandle(), (
int)Zマスクタイプ);
340 bool DrawPart(
int 描画先X座標,
int 描画先Y座標,
int 描画元X原点,
int 描画元Y原点,
int 幅,
int 高さ,
bool 反転フラグ =
false)
const
343 return !DxLib::DrawRectGraph(描画先X座標, 描画先Y座標, 描画元X原点, 描画元Y原点, 幅, 高さ, this->
GetHandle(), this->isTrans, 反転フラグ);
345 SDL_Rect temp = { 描画先X座標, 描画先Y座標, 幅, 高さ };
346 SDL_Rect part = { 描画元X原点 + part.w, 描画元Y原点 + part.h, 幅, 高さ };
347 static SDL_Point point = { 0, 0 };
349 return !SDL_RenderCopyEx(Screen::GetHandle(), handle, &part, &temp, 0, &point, SDL_RendererFlip(反転フラグ));
352 bool ZMaskPart(
int destX,
int destY,
int srcX,
int srcY,
int 幅,
int 高さ , ZMaskType Zマスクタイプ ,
bool 反転フラグ =
false)
const
355 return !DxLib::DrawRectGraph(destX, destY, srcX, srcY, 幅, 高さ, this->
GetHandle(), (
int)Zマスクタイプ, 反転フラグ);
367 DxLib::GetGraphSize( this->
GetHandle() , &w , &h );
368 return DxLib::GetDrawScreenGraph( x , y , x + w , y + h , this->
GetHandle() );
397 return this->isScreen;
403 return this->isAlphaChannel;
409 return this->isTrans;
bool GetIsAlphaChannel() const
αチャンネルフラグを取得.
Definition: Image.h:401
ImageHandle Make(int 幅, int 高さ, bool スクリーン用フラグ=false, bool αチャンネルフラグ=true, bool 透過フラグ=true)
空のイメージを作成.
Definition: Image.h:142
bool Draw(int X座標, int Y座標, bool 反転フラグ=false) const
指定座標に描画.
Definition: Image.h:195
ImageHandle GetHandle() const
ハンドルを取得.
Definition: Image.h:189
bool SetDrawScreen()
描画先にこのイメージに指定.
Definition: Image.h:414
画像データを表すクラス.
Definition: Image.h:37
int GetHeight() const
高さを取得.
Definition: Image.h:385
int GetWidth() const
幅を取得.
Definition: Image.h:375
bool Release()
イメージをメモリから開放.
Definition: Image.h:126
bool DrawPart(int 描画先X座標, int 描画先Y座標, int 描画元X原点, int 描画元Y原点, int 幅, int 高さ, bool 反転フラグ=false) const
一部を指定して描画.
Definition: Image.h:340
bool DrawRotateAxis(int X座標, int Y座標, int X軸, int Y軸, double 拡大率X, double 拡大率Y, double 角度, bool 反転フラグ=false) const
回転軸、角度、拡大率を縦横別に指定して描画.
Definition: Image.h:299
ImageHandle Copy(const Image &元イメージ, int X原点, int Y原点, int 幅, int 高さ)
元イメージの一部をコピーして、別イメージを作成.
Definition: Image.h:168
bool GetIsScreen() const
説明.
Definition: Image.h:395
Image(int 幅, int 高さ, bool スクリーン用フラグ, bool αチャンネルフラグ=true, bool 透過フラグ=true)
空のイメージを作成.
Definition: Image.h:92
bool DrawRotateAxis(int X座標, int Y座標, int X軸, int Y軸, double 拡大率, double 角度, bool 反転フラグ=false) const
回転軸、角度、拡大率を指定して描画.
Definition: Image.h:276
bool DrawExtend(int X座標A, int Y座標A, int X座標B, int Y座標B) const
指定矩形内に描画.
Definition: Image.h:233
bool Load(const char *ファイル名)
画像をメモリへ読み込む.
Definition: Image.h:98
int LoadScreen(int x, int y)
スクリーンの一部をイメージに取り込む.
Definition: Image.h:363
bool DrawModify(int 頂点aX, int 頂点aY, int 頂点bX, int 頂点bY, int 頂点cX, int 頂点cY, int 頂点dX, int 頂点dY) const
四角形に変形描画.
Definition: Image.h:322
bool GetIsTrans() const
透過フラグを取得.
Definition: Image.h:407
bool DrawRotate(int X座標, int Y座標, double 拡大率, double 角度, bool 反転フラグ=false) const
角度、拡大率を指定して描画.
Definition: Image.h:253