Exemple #1
0
        public Image(PDF pdf, System.IO.Stream inputStream, int imageType)
        {
            if (imageType == ImageType.JPEG)
            {
                JPEGImage jpg = new JPEGImage(inputStream);
                data = jpg.GetData();
                w    = jpg.GetWidth();
                h    = jpg.GetHeight();
                if (jpg.GetColorComponents() == 1)
                {
                    addImage(pdf, data, imageType, "DeviceGray", 8);
                }
                else if (jpg.GetColorComponents() == 3)
                {
                    addImage(pdf, data, imageType, "DeviceRGB", 8);
                }
            }
            else if (imageType == ImageType.PNG)
            {
                PNGImage png = new PNGImage(inputStream);
                data = png.GetData();
                w    = png.GetWidth();
                h    = png.GetHeight();
                if (png.colorType == 0)
                {
                    addImage(pdf, data, imageType, "DeviceGray", png.bitDepth);
                }
                else
                {
                    if (png.bitDepth == 16)
                    {
                        addImage(pdf, data, imageType, "DeviceRGB", 16);
                    }
                    else
                    {
                        addImage(pdf, data, imageType, "DeviceRGB", 8);
                    }
                }
            }
            else if (imageType == ImageType.BMP)
            {
                BMPImage bmp = new BMPImage(inputStream);
                data = bmp.GetData();
                w    = bmp.GetWidth();
                h    = bmp.GetHeight();
                addImage(pdf, data, imageType, "DeviceRGB", 8);
            }

            inputStream.Close();
        }
        public Image(PDF pdf, System.IO.Stream inputStream, int imageType)
        {
            if (imageType == ImageType.JPEG) {
            JPEGImage jpg = new JPEGImage(inputStream);
            data = jpg.GetData();
            w = jpg.GetWidth();
            h = jpg.GetHeight();
            if ( jpg.GetColorComponents() == 1 ) {
                addImage(pdf, data, imageType, "DeviceGray", 8);
            }
            else if ( jpg.GetColorComponents() == 3 ) {
                addImage(pdf, data, imageType, "DeviceRGB", 8);
            }
            }
            else if (imageType == ImageType.PNG) {
            PNGImage png = new PNGImage(inputStream);
            data = png.GetData();
            w = png.GetWidth();
            h = png.GetHeight();
            if ( png.colorType == 0 ) {
                addImage(pdf, data, imageType, "DeviceGray", png.bitDepth);
            }
            else {
                if ( png.bitDepth == 16 ) {
                    addImage(pdf, data, imageType, "DeviceRGB", 16);
                }
                else {
                    addImage(pdf, data, imageType, "DeviceRGB", 8);
                }
            }
            }
            else if (imageType == ImageType.BMP) {
            BMPImage bmp = new BMPImage(inputStream);
            data = bmp.GetData();
            w = bmp.GetWidth();
            h = bmp.GetHeight();
            addImage(pdf, data, imageType, "DeviceRGB", 8);
            }

            inputStream.Close();
        }