private static void DrawSmallRaw(Person person, WIC.ImagingFactory wic, D2D.Factory d2dFactory, WIC.FormatConverter converter) { var whRate = 1.0f * converter.Size.Width / converter.Size.Height; var smallRawSize = new Vector2(whRate * ImageDefines.SmallRawY, ImageDefines.SmallRawY); var scale = ImageDefines.SmallRawY / converter.Size.Height; using (var wicBitmap = new WIC.Bitmap(wic, (int)smallRawSize.X, (int)smallRawSize.Y, WIC.PixelFormat.Format32bppPBGRA, WIC.BitmapCreateCacheOption.CacheOnDemand)) using (var target = new D2D.WicRenderTarget(d2dFactory, wicBitmap, new D2D.RenderTargetProperties())) using (var bmp = D2D.Bitmap.FromWicBitmap(target, converter)) using (var bmpBrush = new D2D.BitmapBrush(target, bmp)) { target.BeginDraw(); target.Transform = Matrix3x2.Scaling(scale, scale); target.DrawBitmap(bmp, 1.0f, D2D.BitmapInterpolationMode.Linear); target.EndDraw(); using (var file = File.Create(person.SmallRawImage)) { WicTools.SaveD2DBitmap(wic, wicBitmap, file); } } }
private static void DrawPsd(Person person, WIC.ImagingFactory wic, D2D.Factory d2dFactory, WIC.FormatConverter converter) { using (var wicBitmap = new WIC.Bitmap(wic, (int)ImageDefines.Size, (int)ImageDefines.Size, WIC.PixelFormat.Format32bppPBGRA, WIC.BitmapCreateCacheOption.CacheOnDemand)) using (var target = new D2D.WicRenderTarget(d2dFactory, wicBitmap, new D2D.RenderTargetProperties())) using (var color = new D2D.SolidColorBrush(target, SexColor[person.Sex])) using (var bmp = D2D.Bitmap.FromWicBitmap(target, converter)) using (var bmpBrush = new D2D.BitmapBrush(target, bmp)) { target.BeginDraw(); var offset = (ImageDefines.Size - ImageDefines.RealSize) / 2; bmpBrush.Transform = Matrix3x2.Scaling( ImageDefines.RealSize / bmp.Size.Width, ImageDefines.RealSize / (bmp.Size.Height - 497.0f)) * Matrix3x2.Translation(offset, offset); target.FillEllipse(new D2D.Ellipse( new Vector2(ImageDefines.Size / 2.0f, ImageDefines.Size / 2.0f), ImageDefines.RealSize / 2.0f, ImageDefines.RealSize / 2.0f), bmpBrush); target.DrawEllipse(new D2D.Ellipse( new Vector2(ImageDefines.Size / 2.0f, ImageDefines.Size / 2.0f), ImageDefines.RealSize / 2.0f, ImageDefines.RealSize / 2.0f), color, ImageDefines.LineWidth); target.EndDraw(); using (var file = File.Create(person.PsdImage)) { WicTools.SaveD2DBitmap(wic, wicBitmap, file); } } }