C#語言轉MaxScript語言簡單示例

實現打開本地圖片的方法:

1、MaxScript語言代碼如下:

fn nonLockingBitmapOpen fName =
(
	if not doesFileExist fName do return undefined
	local fs = dotnetObject "System.IO.FileStream" fName (dotnetClass "System.IO.FileMode").open
	local tempBmp = dotnetObject "System.Drawing.Bitmap" fs
	local resultBmp = tempBmp.Clone()
	tempBmp.Dispose();
	fs.Close();
	return resultBmp
)

2、C#語言實現代碼如下:

public Bitamp GetBitmap(string picPath)
{
    FileStream fs = new FileStream(picPath,FileMode.open);
    Bitamp bp = new Bitmap(fs);
    Bitmap result = bp.Clone();
    bp.Disposed();
    fs.Close();
    return result;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章