public static System.Windows.Size[] GetPageBounds(IPDFSource source, ImageRotation rotation = ImageRotation.NONE, string password = null) { using (PDFFileStream stream = new PDFFileStream(source)) { ValidatePassword(stream.Document, password); int pageSize = MuPDFNativeApi.Native.CountPages(stream.Document); return(Enumerable.Range(0, pageSize - 1) .Select(x => { IntPtr ptr = IntPtr.Zero; try { ptr = MuPDFNativeApi.Native.LoadPage(stream.Document, x); MuPDFLibrary.Interop.Rectangle bound = MuPDFNativeApi.Native.BoundPage(stream.Document, ptr); return SizeCallback(rotation)(bound.Width, bound.Height); } finally { if (ptr != IntPtr.Zero) { MuPDFNativeApi.Native.FreePage(stream.Document, ptr); } } }).ToArray()); } }
/// <summary> /// Makes a new instance of <see cref="GlfwWindow"/> class. /// This class manage a crossplatform window. /// </summary> /// <param name="size">Initial window size.</param> /// <param name="title">Initial window title.</param> public GlfwWindow(Vector2i size, string title) { // - Initialize properties Size = new Notify <Vector2i>(size); Position = new Notify <Vector2i>(); Title = new Notify <string>(title); // - Bind properties events Size.Changing += SizeChanging; Position.Changing += PositionChanging; Title.Changing += TitleChanging; // - Initialize callback store pSizeCallback = new SizeCallback((hnd, w, h) => Resized?.Invoke(this, new Vector2(w, h))); }