本文整理汇总了C#中SharpDX.WIC.ImagingFactory类的典型用法代码示例。如果您正苦于以下问题:C# ImagingFactory类的具体用法?C# ImagingFactory怎么用?C# ImagingFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImagingFactory类属于SharpDX.WIC命名空间,在下文中一共展示了ImagingFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BitmapEncoder
/// <summary>
/// Initializes a new instance of the <see cref="BitmapEncoder"/> class.
/// </summary>
/// <param name="factory">The factory.</param>
/// <param name="containerFormatGuid">The container format GUID. List from <see cref="ContainerFormatGuids"/> </param>
/// <param name="stream">A stream to use as the output of this bitmap encoder.</param>
/// <unmanaged>HRESULT IWICImagingFactory::CreateEncoder([In] const GUID& guidContainerFormat,[In, Optional] const GUID* pguidVendor,[Out] IWICBitmapEncoder** ppIEncoder)</unmanaged>
public BitmapEncoder(ImagingFactory factory, Guid containerFormatGuid, System.IO.Stream stream = null)
{
this.factory = factory;
factory.CreateEncoder(containerFormatGuid, null, this);
if (stream != null)
Initialize(stream);
}
示例2: GetColorContexts
internal static ColorContext[] GetColorContexts(ColorContextsProvider getColorContexts, ImagingFactory imagingFactory)
{
ColorContext[] colorContexts;
Result result = TryGetColorContexts(getColorContexts, imagingFactory, out colorContexts);
result.CheckError();
return colorContexts;
}
示例3: TryGetColorContexts
internal static Result TryGetColorContexts(ColorContextsProvider getColorContexts, ImagingFactory imagingFactory, out ColorContext[] colorContexts)
{
colorContexts = null;
int count;
Result result = getColorContexts(0, null, out count);
if (result.Success)
{
colorContexts = new ColorContext[count];
if (count > 0)
{
// http://msdn.microsoft.com/en-us/library/windows/desktop/ee690135(v=vs.85).aspx
// The ppIColorContexts array must be filled with valid data: each IWICColorContext* in the array must
// have been created using IWICImagingFactory::CreateColorContext.
for (int i = 0; i < count; i++)
colorContexts[i] = new ColorContext(imagingFactory);
int actualCount;
getColorContexts(count, colorContexts, out actualCount);
Debug.Assert(count == actualCount);
}
}
return result;
}
示例4: Direct2DFactories
public Direct2DFactories()
{
WICFactory = new WIC.ImagingFactory ();
DWFactory = new DW.Factory ();
var d3DDevice = new D3D11.Device (
D3D.DriverType.Hardware,
D3D11.DeviceCreationFlags.BgraSupport
#if DEBUG
| D3D11.DeviceCreationFlags.Debug
#endif
,
D3D.FeatureLevel.Level_11_1,
D3D.FeatureLevel.Level_11_0,
D3D.FeatureLevel.Level_10_1,
D3D.FeatureLevel.Level_10_0,
D3D.FeatureLevel.Level_9_3,
D3D.FeatureLevel.Level_9_2,
D3D.FeatureLevel.Level_9_1
);
var dxgiDevice = ComObject.As<SharpDX.DXGI.Device> (d3DDevice.NativePointer);
var d2DDevice = new D2D1.Device (dxgiDevice);
D2DFactory = d2DDevice.Factory;
//_d2DDeviceContext = new D2D1.DeviceContext (d2DDevice, D2D1.DeviceContextOptions.None);
//var dpi = DisplayDpi;
//_d2DDeviceContext.DotsPerInch = new Size2F (dpi, dpi);
}
示例5: WICStream
/// <summary>
/// Initializes a new instance of the <see cref="WICStream"/> class from a <see cref="IStream"/>.
/// </summary>
/// <param name="factory">The factory.</param>
/// <param name="stream">The stream.</param>
/// <msdn-id>ee719789</msdn-id>
/// <unmanaged>HRESULT IWICStream::InitializeFromIStream([In, Optional] IStream* pIStream)</unmanaged>
/// <unmanaged-short>IWICStream::InitializeFromIStream</unmanaged-short>
public WICStream(ImagingFactory factory, Stream stream)
: base(IntPtr.Zero)
{
factory.CreateStream(this);
streamProxy = new ComStreamProxy(stream);
var istreamPtr = ComStreamShadow.ToIntPtr(streamProxy);
InitializeFromIStream_(istreamPtr);
}
示例6: GifRecorder
/// <summary>
/// Initializes instance members of the <see cref="GifRecorder"/> class.
/// </summary>
public GifRecorder()
{
GifRepeatCount = 0;
_imagingFactory = new ImagingFactory();
_frames = new List<BitmapFrame>();
MaxFramePerSecond = 8;
_desktopManager = new DesktopManager();
}
示例7: Initialize
public static void Initialize() {
lock (SyncObject) {
if (!_isInitailized) {
_factory = new ImagingFactory();
_isInitailized = true;
}
}
}
示例8: BitmapImpl
/// <summary>
/// Initializes a new instance of the <see cref="BitmapImpl"/> class.
/// </summary>
/// <param name="factory">The WIC imaging factory to use.</param>
/// <param name="stream">The stream to read the bitmap from.</param>
public BitmapImpl(ImagingFactory factory, Stream stream)
{
_factory = factory;
using (BitmapDecoder decoder = new BitmapDecoder(factory, stream, DecodeOptions.CacheOnLoad))
{
WicImpl = new Bitmap(factory, decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnLoad);
}
}
示例9: BitmapImpl
public BitmapImpl(ImagingFactory factory, string fileName)
{
this.factory = factory;
using (BitmapDecoder decoder = new BitmapDecoder(factory, fileName, DecodeOptions.CacheOnDemand))
{
this.WicImpl = new Bitmap(factory, decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnDemand);
}
}
示例10: CCLabel_Renderer81
public CCLabel_Renderer81()
{
var d2dFactory = CreateD2DFactory();
var newDevice = CreateDevice();
CreateRenderingResources(newDevice, d2dFactory);
FactoryImaging = new SharpDX.WIC.ImagingFactory();
}
示例11: LoadBitmaps
private static void LoadBitmaps()
{
var fac = new SharpDX.WIC.ImagingFactory();
var target = GraphicsWindow.Instance.RenderTarget2D;
var stream = new NativeFileStream(Application.StartupPath + "\\Images\\Ship 1.png", NativeFileMode.Open, NativeFileAccess.Read);
var decoder = new BitmapDecoder(fac, stream, DecodeOptions.CacheOnDemand);
var frame = decoder.GetFrame(0);
var converter = new FormatConverter(fac);
converter.Initialize(frame, SharpDX.WIC.PixelFormat.Format32bppPRGBA);
BitShip1 = Bitmap1.FromWicBitmap(GraphicsWindow.Instance.RenderTarget2D, converter);
}
示例12: Main
private static void Main()
{
var wicFactory = new ImagingFactory();
var d2dFactory = new SharpDX.Direct2D1.Factory();
string filename = "output.jpg";
const int width = 512;
const int height = 512;
var rectangleGeometry = new RoundedRectangleGeometry(d2dFactory, new RoundedRectangle() { RadiusX = 32, RadiusY = 32, Rect = new RectangleF(128, 128, width - 128, height-128) });
var wicBitmap = new Bitmap(wicFactory, width, height, SharpDX.WIC.PixelFormat.Format32bppBGR, BitmapCreateCacheOption.CacheOnLoad);
var renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default, new PixelFormat(Format.Unknown, AlphaMode.Unknown), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);
var d2dRenderTarget = new WicRenderTarget(d2dFactory, wicBitmap, renderTargetProperties);
var solidColorBrush = new SolidColorBrush(d2dRenderTarget, Color.White);
d2dRenderTarget.BeginDraw();
d2dRenderTarget.Clear(Color.Black);
d2dRenderTarget.FillGeometry(rectangleGeometry, solidColorBrush, null);
d2dRenderTarget.EndDraw();
if (File.Exists(filename))
File.Delete(filename);
var stream = new WICStream(wicFactory, filename, NativeFileAccess.Write);
// Initialize a Jpeg encoder with this stream
var encoder = new JpegBitmapEncoder(wicFactory);
encoder.Initialize(stream);
// Create a Frame encoder
var bitmapFrameEncode = new BitmapFrameEncode(encoder);
bitmapFrameEncode.Initialize();
bitmapFrameEncode.SetSize(width, height);
var pixelFormatGuid = SharpDX.WIC.PixelFormat.FormatDontCare;
bitmapFrameEncode.SetPixelFormat(ref pixelFormatGuid);
bitmapFrameEncode.WriteSource(wicBitmap);
bitmapFrameEncode.Commit();
encoder.Commit();
bitmapFrameEncode.Dispose();
encoder.Dispose();
stream.Dispose();
System.Diagnostics.Process.Start(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory,filename)));
}
示例13: RenderTargetBitmapImpl
public RenderTargetBitmapImpl(
ImagingFactory imagingFactory,
Factory d2dFactory,
int width,
int height)
: base(imagingFactory, width, height)
{
this.target = new WicRenderTarget(
d2dFactory,
this.WicImpl,
new RenderTargetProperties
{
DpiX = 96,
DpiY = 96,
});
}
示例14: RenderTargetBitmapImpl
public RenderTargetBitmapImpl(
ImagingFactory imagingFactory,
Factory d2dFactory,
int width,
int height)
: base(imagingFactory, width, height)
{
var props = new RenderTargetProperties
{
DpiX = 96,
DpiY = 96,
};
_target = new WicRenderTarget(
d2dFactory,
WicImpl,
props);
}
示例15: Direct2D1RenderTargetBitmap
public Direct2D1RenderTargetBitmap(
Factory d2dFactory,
ImagingFactory wicFactory,
SharpDX.WIC.Bitmap bitmap)
: base(wicFactory, bitmap)
{
double dpiX;
double dpiY;
this.d2dFactory = d2dFactory;
bitmap.GetResolution(out dpiX, out dpiY);
this.target = new WicRenderTarget(
d2dFactory,
bitmap,
new RenderTargetProperties
{
DpiX = (float)dpiX,
DpiY = (float)dpiY,
});
}