[問題] 請問SDL的部分程式碼問題

看板C_and_CPP作者 (yolling)時間12年前 (2012/07/19 16:38), 編輯推噓1(107)
留言8則, 3人參與, 最新討論串1/2 (看更多)
請問一下,我經版友的推薦,目前在http://ppt.cc/lnwu學SDL 我看到第二章Optimized Surface Loading and Blitting 的部分 裡面有段副程式如下: SDL_Surface *load_image(std::string FileName){ SDL_Surface *LoadedImage = NULL; SDL_Surface *OptimizedImage = NULL;  LoadedImage=SDL_LoadBMP(FileName.c_str()); if(LoadedImage!=NULL){ OptimizedImage = SDL_DisplayFormat(LoadedImage); SDL_FreeSurface(LoadedImage); } return OptimizedImage; } 我想請問的是那個if判斷的是如果圖片讀到的非NULL就成立 接著執行SDL_DisplayFormat(LoadedImage); 可是我不太懂他解釋這段的意思 『 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. 』 可以請高手們幫忙解釋嗎?謝謝 因為在此教學的第一章中,明明同樣是讀取BMP檔,但卻不需要使用SDL_DisplayFormat 所以對此有點困惑。 另外有些英文單字可以的話也想請各位幫忙解釋一下 surface、stick、bilt請問該怎麼解釋? 另外『Now SDL won't have to convert it on the fly.』此文中的fly又是什麼意思? 謝謝各位的幫忙 另外這SDL的網頁真的滿不錯的,教的很詳細, 而且用的句子讓我這個英文初學者幾乎都看得懂@@ 讓我對英文有一點點的信心了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.0.51.8 ※ 編輯: yoll522 來自: 123.0.51.8 (07/19 16:39) ※ 編輯: yoll522 來自: 123.0.51.8 (07/19 16:41) ※ 編輯: yoll522 來自: 123.0.51.8 (07/19 16:49)

07/19 16:53, , 1F
Surface算是圖片、平面等,Blit就算是貼圖的動作
07/19 16:53, 1F

07/19 19:01, , 2F
stick就是「黏」。你有字典吧?
07/19 19:01, 2F

07/19 19:02, , 3F
on the fly是一個片語(你有字…),意思是當下就處理
07/19 19:02, 3F

07/19 19:02, , 4F
不透過暫存檔或中間階段。以前用燒錄軟體經常會看到。
07/19 19:02, 4F

07/19 20:40, , 5F
因為我都是用google翻譯的,我輸入on the fly他是顯示
07/19 20:40, 5F

07/19 20:41, , 6F
『於飛』所以覺得還滿奇怪的,stick有翻到是黏,可是覺得
07/19 20:41, 6F

07/19 20:41, , 7F
怪怪的所以想說問一下,謝謝各位的幫忙
07/19 20:41, 7F

07/19 22:52, , 8F
阿把影像黏到平面上,就是貼圖阿
07/19 22:52, 8F
文章代碼(AID): #1G1yU0Hu (C_and_CPP)
文章代碼(AID): #1G1yU0Hu (C_and_CPP)