Beispiel #1
0
        public void NativeMethods_StructureArrayToIntPtr_Call_AllocatedIntPtr()
        {
            var array  = new FPDF_COLOR[] { new FPDF_COLOR(0, 1, 2, 3), new FPDF_COLOR(0, 1, 2, 3), new FPDF_COLOR(0, 1, 2, 3) };
            var intPtr = NativeMethods.StructureArrayToIntPtr(array);

            Assert.IsTrue(intPtr.ToInt64() != 0);
            Marshal.FreeHGlobal(intPtr);
        }
        public void FPDFCOLOR_AllProperties_Test_Success_02()
        {
            var c = new FPDF_COLOR(1, 2, 3, 4);

            Assert.AreEqual(1, c.Red);
            Assert.AreEqual(2, c.Green);
            Assert.AreEqual(3, c.Blue);
            Assert.AreEqual(4, c.Alpha);
        }
        public void FPDFCOLOR_AllProperties_Test_Success_01()
        {
            var c = new FPDF_COLOR(0x0A0B0C0D);

            Assert.AreEqual(0x0B, c.Red);
            Assert.AreEqual(0x0C, c.Green);
            Assert.AreEqual(0x0D, c.Blue);
            Assert.AreEqual(0x0A, c.Alpha);
        }
Beispiel #4
0
        /// <summary>
        /// Render the rectangle to the bitmap.
        /// </summary>
        /// <param name="zoomFactor">Zoom factor to use for transformation.</param>
        /// <param name="startX">Left pixel position of the page area to render.</param>
        /// <param name="startY">Top pixel position of the page area to render.</param>
        /// <param name="sizeY">Height of the page area to render.</param>
        /// <param name="rectStartX">Left pixel position of the rectangle to render.</param>
        /// <param name="rectStartY">Top pixel position of the rectangle to render.</param>
        /// <param name="rectSizeX">Width of the rectangle to render.</param>
        /// <param name="rectSizeY">Height of the rectangle to render.</param>
        public void RenderSelectionRectangle(
            double zoomFactor,
            int startX,
            int startY,
            int sizeY,
            double rectStartX,
            double rectStartY,
            double rectSizeX,
            double rectSizeY)
        {
            int left   = (int)Math.Round(rectStartX * zoomFactor, 0) + startX - 2;
            int top    = sizeY - (int)Math.Round(rectStartY * zoomFactor, 0) + startY - 2;
            int width  = (int)Math.Round(rectSizeX * zoomFactor, 0) + 4;
            int height = -(int)Math.Round(rectSizeY * zoomFactor, 0) + 4;

            // Colors
            var colorBackground = new FPDF_COLOR(0xFF, 0xFF, 0xA0, 0x3F);
            var colorBorder     = new FPDF_COLOR(0x00, 0x00, 0xFF, 0xFF);

            if (_mainComponent.PageComponent is IPDFPageComponent pageComponent)
            {
                if (_mainComponent.PageComponent.FindSelectionBackgroundFunc != null)
                {
                    colorBackground = new FPDF_COLOR(_mainComponent.PageComponent.FindSelectionBackgroundFunc());
                }

                if (_mainComponent.PageComponent.FindSelectionBorderFunc != null)
                {
                    colorBorder = new FPDF_COLOR(_mainComponent.PageComponent.FindSelectionBorderFunc());
                }
            }

            // Background
            _mainComponent.PDFiumBridge.FPDFBitmap_FillRect(_bitmapHandle, left, top, width, height, colorBackground);

            // Bottom border
            _mainComponent.PDFiumBridge.FPDFBitmap_FillRect(_bitmapHandle, left - 2, top + height, width + 4, 2, colorBorder);

            // Top border
            _mainComponent.PDFiumBridge.FPDFBitmap_FillRect(_bitmapHandle, left - 2, top - 2, width + 2, 2, colorBorder);

            // Left border
            _mainComponent.PDFiumBridge.FPDFBitmap_FillRect(_bitmapHandle, left - 2, top - 2, 2, height + 2, colorBorder);

            // Right border
            _mainComponent.PDFiumBridge.FPDFBitmap_FillRect(_bitmapHandle, left + width, top - 2, 2, height + 2, colorBorder);
        }
Beispiel #5
0
 /// <summary>
 /// Fills a rectangle in the <see cref="PDFiumBitmap"/> with <paramref name="color"/>.
 /// The pixel values in the rectangle are replaced and not blended.
 /// </summary>
 public void FillRectangle(int left, int top, int width, int height, FPDF_COLOR color)
 {
     PDFium.FPDFBitmap_FillRect(Handle, left, top, width, height, color);
 }
Beispiel #6
0
 /// <summary>
 /// Fills the whole <see cref="PDFiumBitmap"/> with <paramref name="color"/>.
 /// The pixel values in the rectangle are replaced and not blended.
 /// </summary>
 /// <param name="color"></param>
 public void Fill(FPDF_COLOR color) => FillRectangle(0, 0, Width, Height, color);
 public void FPDFCOLOR_Constructor_Call_NoException_03()
 {
     _ = new FPDF_COLOR(1, 2, 3, 4);
 }
 public void FPDFCOLOR_Constructor_Call_NoException_02()
 {
     _ = new FPDF_COLOR(0);
 }