Beispiel #1
0
        internal virtual void writeImage(System.Drawing.Bitmap image)
        {
            //UPGRADE_TODO: Class 'java.awt.image.WritableRaster' was converted to 'System.Drawing.Bitmap' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtimageWritableRaster_3"'
            System.Drawing.Bitmap raster = image;
            System.IO.MemoryStream tempDataBuffer;
            tempDataBuffer = new System.IO.MemoryStream();
            //UPGRADE_TODO: Method 'java.awt.image.Raster.getDataBuffer' was converted to 'System.Drawing.Bitmap' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtimageRastergetDataBuffer_3"'
            raster.Save(tempDataBuffer, System.Drawing.Imaging.ImageFormat.Bmp);
            System.Collections.ArrayList buffer = new System.Collections.ArrayList(tempDataBuffer.ToArray());
            //UPGRADE_TODO: Class 'java.awt.image.SampleModel' was converted to 'System.Drawing.Bitmap' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtimageSampleModel_3"'
            System.Drawing.Bitmap sampleModel = raster;
            int sampleSize = getPixelSize(sampleModel);
            //UPGRADE_ISSUE: Method 'java.awt.image.Raster.getSampleModelTranslateX' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtimageRastergetSampleModelTranslateX_3"'
            //UPGRADE_ISSUE: Method 'java.awt.image.Raster.getSampleModelTranslateY' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtimageRastergetSampleModelTranslateY_3"'
            int offset = (- raster.getSampleModelTranslateX() - raster.getSampleModelTranslateY() * sampleModel.Width) * sampleSize;
            int pitch = sampleModel.Width * sampleSize;

            //		System.out.println("sample size " + sampleSize + " offset " + offset + " pitch " + pitch);

            if ((int) image.PixelFormat == (int) System.Drawing.Imaging.PixelFormat.Format24bppRgb)
            {
                //UPGRADE_ISSUE: Method 'java.awt.image.BufferedImage.getColorModel' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtimageBufferedImagegetColorModel_3"'
                SupportClass.IndexedColorArray cm = (SupportClass.IndexedColorArray) image.getColorModel();
                int w = image.Width;
                int h = image.Height;
                int[] colors = new int[256];
                int[] data = new int[w * h];
                sbyte[] src = SupportClass.ToSByteArray((byte[]) ((System.Collections.ArrayList) buffer)[0]);

                //UPGRADE_ISSUE: Method 'java.awt.image.IndexColorModel.getRGBs' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtimageIndexColorModelgetRGBs_int[]_3"'
                cm.getRGBs(colors);
                for (int i = 0; i < w * h; i++)
                {
                    data[i] = colors[(int) src[i] & 0xff];
                }
                write(0, 0, width, height, data, Format.A8R8G8B8);
                return ;
            }

            if (buffer is System.Collections.ArrayList)
            {
                System.Collections.ArrayList byteBuffer = (System.Collections.ArrayList) buffer;
                write(0, 0, width, height, SupportClass.ToSByteArray((byte[]) byteBuffer[0]), format, offset, pitch);
            }
            else if (buffer is System.Collections.ArrayList)
            {
                System.Collections.ArrayList intBuffer = (System.Collections.ArrayList) buffer;

                write(0, 0, width, height, (int[]) intBuffer[0], format, offset / 4, pitch / 4);
            }
            else
                throw new System.ArgumentException("Unsupported DataBuffer type");
        }
Beispiel #2
0
        /// <summary> Creates an image from the given BufferedImage. 
        /// 
        /// </summary>
        /// <param name="image">the source image.
        /// </param>
        public Image(System.Drawing.Bitmap image)
        {
            //		System.out.println("new ScenicImage from BufferedImage " + image);
            //UPGRADE_ISSUE: Method 'java.awt.image.BufferedImage.getColorModel' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtimageBufferedImagegetColorModel_3"'
            System.Drawing.Color tempAux = image.getColorModel();
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            int fmt = getScenicFormat((int) image.PixelFormat, ref tempAux);

            create(image.Width, image.Height, fmt);

            writeImage(image);
        }