public static D2D_RECT_F RectF(float left = 0.0f, float top = 0.0f, float right = 0.0f, float bottom = 0.0f) { D2D_RECT_F rect = new D2D_RECT_F { left = left, top = top, right = right, bottom = bottom, }; return(rect); }
static void BuildAtlasWithGPU(int thumbSize = 96, int dimension = 20) { using (var memBmp = new WicBitmapSource(thumbSize * dimension, thumbSize * dimension, WicPixelFormat.GUID_WICPixelFormat32bppPRGBA)) { using (var dc = memBmp.CreateDeviceContext()) { var row = 0; var col = 0; var path = @"d:\temp"; var sw = new Stopwatch(); sw.Start(); foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly)) { var ext = Path.GetExtension(file); if (!WicImagingComponent.DecoderFileExtensions.Contains(ext)) { continue; } if (new FileInfo(file).Length < 32) { continue; } using (var bmp = WicBitmapSource.Load(file)) { bmp.Scale(thumbSize, WICBitmapInterpolationMode.WICBitmapInterpolationModeFant); if (bmp.PixelFormat != WicPixelFormat.GUID_WICPixelFormat32bppPRGBA) { bmp.ConvertTo(WicPixelFormat.GUID_WICPixelFormat32bppPRGBA); } using (var cb = dc.CreateBitmapFromWicBitmap(bmp.ComObject)) { var dr = D2D_RECT_F.Sized(col * thumbSize, row * thumbSize, bmp.Width, bmp.Height); dc.BeginDraw(); dc.DrawBitmap(cb, destinationRectangle: dr); dc.EndDraw(); } } col++; if (col > dimension) { col = 0; row++; } } Console.WriteLine(sw.Elapsed); } memBmp.Save("atlas.jpg"); } }
public D2D1_IMAGE_BRUSH_PROPERTIES([NativeTypeName("D2D1_RECT_F")] D2D_RECT_F sourceRectangle, D2D1_EXTEND_MODE extendModeX = D2D1_EXTEND_MODE_CLAMP, D2D1_EXTEND_MODE extendModeY = D2D1_EXTEND_MODE_CLAMP, D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR) { this = ImageBrushProperties(sourceRectangle, extendModeX, extendModeY, interpolationMode); }
public static extern void Direct2D_DrawDynamicBitmap(IntPtr pBitmap, D2D_RECT_F drect, D2DBitmapInterpolationMode interpolationMode);
public D2D1_EFFECT_INPUT_DESCRIPTION(ID2D1Effect *effect, [NativeTypeName("UINT32")] uint inputIndex, [NativeTypeName("D2D1_RECT_F")] D2D_RECT_F inputRectangle) { this = EffectInputDescription(effect, inputIndex, inputRectangle); }
public static extern void Direct2D_DrawStaticBitmap(IntPtr pBitmap, D2D_RECT_F drect);
public static extern void Direct2D_DrawTextFormat(IntPtr pTextFormat, string text, D2D_RECT_F drect, D2DSolidColorBrush brush);
public static extern void Direct2D_FillEllipse(D2D_RECT_F drect, D2DSolidColorBrush brush);
public static extern void Direct2D_DrawEllipse(D2D_RECT_F drect, float strokeWidth, D2DSolidColorBrush brush);
public static extern void Direct2D_PushAxisAlignedClip(D2D_RECT_F drect, D2DAntiAliasMode antialiasMode);