[英]Missing EditingSession and FilterFactory in Nokia Imaging SDK v1.2.115.0 HDR example
我正在嘗試在我的項目中使用此代碼 ,但似乎在SDK v1.2.115.0中不再支持EditingSession
和FilterFactory
類
原始碼
WriteableBitmap toneMap1 = new WriteableBitmap(CapturedImage.PixelWidth, CapturedImage.PixelHeight);
using (EditingSession editsession = new EditingSession(image1.AsBitmap()))
using (EditingSession blendSession = new EditingSession(image1.AsBitmap()))
{
// Create the blurred version of original image
editsession.AddFilter(FilterFactory.CreateBlurFilter(BlurLevel.Blur1));
// Perform the difference between the original image and the blurred copy
editsession.AddFilter(FilterFactory.CreateBlendFilter(blendSession, BlendFunction.Difference));
// Create the Laplacian of the original image using the emboss filter
blendSession.AddFilter(FilterFactory.CreateEmbossFilter(1.0f));
// Add the result of blur with emboss filter
editsession.AddFilter(FilterFactory.CreateBlendFilter(blendSession, BlendFunction.Add));
// Perform a gray scale as we need just informations on radiance not colours
editsession.AddFilter(FilterFactory.CreateGrayscaleFilter());
// Render the result
await editsession.RenderToWriteableBitmapAsync(toneMap1, OutputOption.PreserveAspectRatio);
}
到目前為止,這是我嘗試過的
IList<IFilter> filtersList = new List<IFilter>();
var blurFilter = new BlurFilter()
{
BlurRegionShape = BlurRegionShape.Rectangular,
KernelSize = 10
};
var blendFilter = new BlendFilter()
{
BlendFunction = BlendFunction.Difference,
};
var embossFilter = new EmbossFilter()
{
Level = 1.0f
};
var blendFilter2 = new BlendFilter()
{
BlendFunction = BlendFunction.Add
};
var grayScaleFilter = new GrayscaleFilter();
filtersList.Add(blurFilter);
filtersList.Add(blendFilter);
filtersList.Add(embossFilter);
filtersList.Add(blendFilter2);
filtersList.Add(grayScaleFilter);
using (var ms = new MemoryStream())
{
image1.SaveJpeg(ms, image1.PixelWidth, image1.PixelHeight, 0, 100);
ms.Position = 0;
using (var streamImageSource1 = new StreamImageSource(ms))
using (var filterEffect1 = new FilterEffect(streamImageSource1) { Filters = filtersList })
using (var writableBitmapRenderer1 = new WriteableBitmapRenderer(filterEffect1, toneMap1))
{
toneMap1 = await writableBitmapRenderer1.RenderAsync();
}
}
因為BlendFilter的ForegroundSource
為空,所以引發了錯誤。 ForegroundSource
應該是先前過濾器(在本例中為blurFilter和embossFilter)的結果,不是嗎?
但是,由於我無法使用EditingSession
和FilterFactory
,如何正確更改代碼以使其與更新的SDK一起使用?
我想我知道了。 對於那些在同一條船上的人,這就是我所做的
using (var ms = new MemoryStream())
{
image2.SaveJpeg(ms, image2.PixelWidth, image2.PixelHeight, 0, 100);
ms.Position = 0;
using (var oriStreamImageSource2 = new StreamImageSource(ms))
{
//Create the blurred version of original image
var blurEffect = new FilterEffect(oriStreamImageSource2)
{
Filters = new[] { new BlurFilter() { KernelSize = BlurLevel } }
};
var blendEffect1 = new FilterEffect(blurEffect)
{
Filters = new[] { new BlendFilter(oriStreamImageSource2, BlendFunction.Difference) }
};
//Create the Laplacian of the original image using the emboss filter
var embossEffect = new FilterEffect(oriStreamImageSource2)
{
Filters = new[] { new EmbossFilter(1.0f) }
};
//Add the result of blur with emboss filter
var blendEffect2 = new FilterEffect(blendEffect1)
{
Filters = new[] { new BlendFilter(embossEffect, BlendFunction.Add) }
};
//Perform a gray scale as we need just informations on radiance not colours
var grayScaleEffect = new FilterEffect(blendEffect2)
{
Filters = new[] { new GrayscaleFilter() }
};
using (var writableBitmapRenderer = new WriteableBitmapRenderer(grayScaleEffect, toneMap2))
{
toneMap2 = await writableBitmapRenderer.RenderAsync();
blurEffect.Dispose();
blendEffect1.Dispose();
embossEffect.Dispose();
blendEffect2.Dispose();
grayScaleEffect.Dispose();
}
};
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.