protected override RectInt32 OnGetMaxRenderBounds() { RectDouble a = this.BaseTransform.Transform(this.baseBounds); RectDouble b = this.FinalTransform.Transform(this.baseBounds); return(RectDouble.Union(a, b).Int32Bound); }
private PlacedBitmap CreateFontPreview(string gdiFontName, float fontSize, PaintDotNet.UI.Media.Brush textBrush) { FontProperties fontProperties; TextMetrics metrics; OverhangMetrics overhangMetrics; try { fontProperties = this.fontMap.GetFontProperties(gdiFontName); using (IDrawingContext context = DrawingContext.CreateNull(FactorySource.PerThread)) { TextLayoutAlgorithm?layoutAlgorithm = null; TextLayout resourceSource = UIText.CreateLayout(context, this.fontSampleText, fontProperties, (double)fontSize, layoutAlgorithm, HotkeyRenderMode.Ignore, 65535.0, 65535.0); ITextLayout cachedOrCreateResource = context.GetCachedOrCreateResource <ITextLayout>(resourceSource); metrics = cachedOrCreateResource.Metrics; overhangMetrics = cachedOrCreateResource.OverhangMetrics; } } catch (Exception exception) { if ((!(exception is NoFontException) && !(exception is FontFileAccessException)) && (!(exception is FontFileFormatException) && !(exception is FontFileNotFoundException))) { throw; } Surface cleanupObject = Surface.CopyFromGdipImage(PdnResources.GetImageResource("Icons.WarningIcon.png").Reference); BitmapProxy proxy = new BitmapProxy(cleanupObject.CreateAliasedImagingBitmap(), ObjectRefProxyOptions.AssumeOwnership); proxy.AddCleanupObject(cleanupObject); return(new PlacedBitmap(proxy, new RectDouble(0.0, 0.0, (double)proxy.Size.Width, (double)proxy.Size.Height), true)); } RectDouble a = new RectDouble((double)metrics.Left, (double)metrics.Top, (double)(metrics.Left + metrics.WidthMax), (double)(metrics.Top + metrics.Height)); RectDouble b = RectDouble.FromEdges((double)(metrics.Left - overhangMetrics.Left), (double)(metrics.Top - overhangMetrics.Top), (double)(metrics.LayoutWidth + overhangMetrics.Right), (double)(metrics.LayoutHeight + overhangMetrics.Bottom)); RectInt32 num4 = RectDouble.Union(a, b).Int32Bound; IBitmap bitmap = new PaintDotNet.Imaging.Bitmap(num4.Width, num4.Height, PixelFormats.Pbgra32, BitmapCreateCacheOption.CacheOnLoad); using (IDrawingContext context2 = DrawingContext.FromBitmap(bitmap, FactorySource.PerThread)) { context2.Clear(null); using (context2.UseTranslateTransform((float)-num4.X, (float)-num4.Y, MatrixMultiplyOrder.Prepend)) { using (context2.UseTextRenderingMode(TextRenderingMode.Outline)) { TextLayout textLayout = UIText.CreateLayout(context2, this.fontSampleText, fontProperties, (double)fontSize, null, HotkeyRenderMode.Ignore, 65535.0, 65535.0); context2.TextAntialiasMode = TextAntialiasMode.Grayscale; context2.DrawTextLayout(0.0, 0.0, textLayout, textBrush, DrawTextOptions.None); } } } return(new PlacedBitmap(bitmap, b, true)); }
RectInt32 IBitmapLayerTransactionHandlerHost <TDerived, TChanges> .GetDifferentialMaxBounds(TChanges oldChanges, TChanges newChanges) { object renderDataCurrencyToken = oldChanges.RenderDataCurrencyToken; object newCurrencyToken = newChanges.RenderDataCurrencyToken; IList <int> list = newChanges.RenderData.EnumerateStrokeSampleIndicesBetweenCurrencyTokens(renderDataCurrencyToken, newCurrencyToken); if (list.Count == 0) { return(newChanges.GetMaxRenderBounds()); } SizeDouble size = newChanges.Stamp.Size; RectDouble bounds = newChanges.RenderData.StrokeSamples[list[0]].GetBounds(size); int count = list.Count; for (int i = 1; i < count; i++) { int num5 = list[i]; RectDouble b = newChanges.RenderData.StrokeSamples[num5].GetBounds(size); bounds = RectDouble.Union(bounds, b); } return(bounds.Int32Bound); }