iTextSharp.text.Image.ScalePercent C# (CSharp) Метод

ScalePercent() публичный Метод

Scale the width and height of an image to a certain percentage.
public ScalePercent ( float percentX, float percentY ) : void
percentX float the scaling percentage of the width
percentY float the scaling percentage of the height
Результат void
        public void ScalePercent(float percentX, float percentY)
        {
            plainWidth = (this.Width * percentX) / 100f;
            plainHeight = (this.Height * percentY) / 100f;
            float[] matrix = Matrix;
            scaledWidth = matrix[DX] - matrix[CX];
            scaledHeight = matrix[DY] - matrix[CY];
            WidthPercentage = 0;
        }

Same methods

Image::ScalePercent ( float percent ) : void

Usage Example

Пример #1
0
        private void AddCover()
        {
            try
            {
                byte[] cover = WebCrawler.DownloadCover(lnParameters.urlCover);

                PdfImage pic = PdfImage.GetInstance(cover);

                if (pic.Height > pic.Width)
                {
                    //Maximum height is 800 pixels.
                    float percentage = 0.0f;
                    percentage = 700 / pic.Height;
                    pic.ScalePercent(percentage * 100);
                }
                else
                {
                    //Maximum width is 600 pixels.
                    float percentage = 0.0f;
                    percentage = 540 / pic.Width;
                    pic.ScalePercent(percentage * 100);
                }

                pic.Border      = Rectangle.BOX;
                pic.BorderColor = BaseColor.BLACK;
                pic.BorderWidth = 3f;
                pdf.NewPage();
                pdf.Add(pic);
            }
            catch (CoverException)
            {}
        }
All Usage Examples Of iTextSharp.text.Image::ScalePercent