private string GetTexture(BaseContainer data, BaseChannel matChannel) { string resultName = null; string texture = data.GetString(C4dApi.BASECHANNEL_TEXTURE); if (!string.IsNullOrEmpty(texture)) { texture = Path.GetFileNameWithoutExtension(texture); texture += ".jpg"; resultName = texture; if (!_textureFiles.Contains(texture)) { matChannel.InitTexture(new InitRenderStruct(_doc)); using (BaseBitmap bitmap = matChannel.GetBitmap()) { if (bitmap != null) { using (BaseContainer compressionContainer = new BaseContainer(C4dApi.JPGSAVER_QUALITY)) { bool bRet = bitmap.SetColorProfile(ColorProfile.GetDefaultSRGB()); compressionContainer.SetFloat(C4dApi.JPGSAVER_QUALITY, 70.0); string textureFileAbs = Path.Combine(_sceneRootDir, texture); bitmap.Save(new Filename(textureFileAbs), C4dApi.FILTER_JPG, compressionContainer, SAVEBIT.SAVEBIT_0); _textureFiles.Add(texture); } } else { resultName = null; } } matChannel.FreeTexture(); } } return(resultName); }
/// <summary> /// Saves the FastBitmap to a file using a specific format. /// </summary> /// <param name="filename">The path of the image file.</param> /// <param name="format">The format of the image file.</param> public void Save(string filename, ImageFormat format) => BaseBitmap.Save(filename, format);
/// <summary> /// Saves the FastBitmap to a file. /// </summary> /// <param name="filename">The path of the image file.</param> public void Save(string filename) => BaseBitmap.Save(filename);