Код: Выделить всё
// Crop bitmap
public static void CropBitmap(IPBBitmap InBitmap, float clipU, float clipV, float clipW, float clipH)
{
string filename = InBitmap.Bi.PathEx.CStr;
string actualPath = GetActualPath(filename);
string actualFileName = System.IO.Path.GetFileName(actualPath);
string actualFilePath = System.IO.Path.GetDirectoryName(actualPath);
string actualFileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(actualPath);
string actualFileExtension = System.IO.Path.GetExtension(actualPath);
string newFileName = System.IO.Path.Combine(actualFilePath, $"{actualFileNameWithoutExtension}_crop{actualFileExtension}");
float width = InBitmap.Bi.Width * clipW;
float height = InBitmap.Bi.Height * clipH;
var inBitmapInfo = InBitmap.Bi;
IBitmapInfo bitmapInfo = InBitmap.Bi;
bitmapInfo.SetType(inBitmapInfo.Type);
bitmapInfo.SetGamma(inBitmapInfo.Gamma);
bitmapInfo.SetWidth((ushort)width);
bitmapInfo.SetHeight((ushort)height);
bitmapInfo.SetName(newFileName);
Debug.Print($"Bi : {bitmapInfo}");
// RedHaloCore.Global is GlobalInterface.Instance
IBitmap newBitmap = RedHaloCore.Global.TheManager.Create(bitmapInfo);
if (newBitmap == null)
{
Debug.Print($"new bitmap: {newBitmap}");
}
else
{
Debug.Print($"ERROR, can't create bitmap");
}
}
< /code>
печатное сообщение: < /p>
bi: autodesk.max.wrappers.bitmapinfo < /p>
Ошибка, не могу создать растровый < /p>
< /blockquote>
, когда я использую их, (я использую. возвращается всегда null Подробнее здесь: https://stackoverflow.com/questions/796 ... ds-max-sdk