Re: [問題] 請問SDL的部分程式碼問題
First the image is loaded using SDL_LoadBMP().
But it shouldn't be used immediately because the bitmap is 24-bit.
The screen is 32-bit and it's not a good idea to blit a surface onto
another surface that is a different format because SDL will have to
change the format on the fly which causes slow down.
第一件事先用 SDL_LoadBMP() 讀取 image, 但是不能馬上使用因為圖是 24-bit
但螢幕卻是 32-bit, 硬要將圖貼上的話 SDL 必須很快的轉換格式從而造成效能低落
---------------------------------------------------------------------------
If the image loaded fine, SDL_DisplayFormat() is called which creates a new
version of "loadedImage" in the same format as the screen. The reason we do
this is because when you try to stick one surface onto another one of a
different format, SDL converts the surface so they're the same format.
SDL_DisplayFormat 是把傳入的 surface 轉成跟螢幕一樣的格式並儲存起來, 而不用
每次都把格式轉成一樣再貼上去
So now we have 2 surfaces, the old loaded image and the new optimized image.
大概就是這樣, 有錯請指正
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 36.229.84.166
→
07/19 20:41, , 1F
07/19 20:41, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章