Example #1
0
		public object Clone() {
			ComplexImage image = new ComplexImage();
			Complex[,] complexArray = new Complex[this.height, this.width];
			image.data = complexArray;
			image.width = this.width;
			image.height = this.height;
			image.fmode = this.fmode;
			for (int i = 0; i < this.height; i++) {
				for (int j = 0; j < this.width; j++) {
					complexArray[i, j] = this.data[i, j];
				}
			}
			return image;
		}
Example #2
0
        public static unsafe ComplexImage FromBitmap(Bitmap srcImg)
        {
            int width  = srcImg.Width;
            int height = srcImg.Height;

            if (!Tools.IsPowerOf2(width) || !Tools.IsPowerOf2(height))
            {
                throw new ArgumentException();
            }
            ComplexImage image = new ComplexImage();

            Complex[,] complexArray = new Complex[height, width];
            image.data   = complexArray;
            image.width  = width;
            image.height = height;
            BitmapData bitmapdata = srcImg.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, srcImg.PixelFormat);
            int        num3       = bitmapdata.Stride - ((srcImg.PixelFormat == PixelFormat.Format8bppIndexed) ? width : (width * 3));
            byte *     numPtr     = (byte *)bitmapdata.Scan0.ToPointer();

            if (srcImg.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                for (int i = 0; i < height; i++)
                {
                    int num5 = 0;
                    while (num5 < width)
                    {
                        complexArray[i, num5].Re = ((float)numPtr[0]) / 255f;
                        num5++;
                        numPtr++;
                    }
                    numPtr += num3;
                }
            }
            else
            {
                for (int j = 0; j < height; j++)
                {
                    int num7 = 0;
                    while (num7 < width)
                    {
                        complexArray[j, num7].Re = (((0.2125f * numPtr[2]) + (0.7154f * numPtr[1])) + (0.0721f * numPtr[0])) / 255f;
                        num7++;
                        numPtr += 3;
                    }
                    numPtr += num3;
                }
            }
            srcImg.UnlockBits(bitmapdata);
            return(image);
        }
Example #3
0
        public object Clone()
        {
            ComplexImage image = new ComplexImage();

            Complex[,] complexArray = new Complex[this.height, this.width];
            image.data   = complexArray;
            image.width  = this.width;
            image.height = this.height;
            image.fmode  = this.fmode;
            for (int i = 0; i < this.height; i++)
            {
                for (int j = 0; j < this.width; j++)
                {
                    complexArray[i, j] = this.data[i, j];
                }
            }
            return(image);
        }
Example #4
0
		public static unsafe ComplexImage FromBitmap(Bitmap srcImg) {
			int width = srcImg.Width;
			int height = srcImg.Height;
			if (!Tools.IsPowerOf2(width) || !Tools.IsPowerOf2(height)) {
				throw new ArgumentException();
			}
			ComplexImage image = new ComplexImage();
			Complex[,] complexArray = new Complex[height, width];
			image.data = complexArray;
			image.width = width;
			image.height = height;
			BitmapData bitmapdata = srcImg.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, srcImg.PixelFormat);
			int num3 = bitmapdata.Stride - ((srcImg.PixelFormat == PixelFormat.Format8bppIndexed) ? width : (width * 3));
			byte* numPtr = (byte*)bitmapdata.Scan0.ToPointer();
			if (srcImg.PixelFormat == PixelFormat.Format8bppIndexed) {
				for (int i = 0; i < height; i++) {
					int num5 = 0;
					while (num5 < width) {
						complexArray[i, num5].Re = ((float)numPtr[0]) / 255f;
						num5++;
						numPtr++;
					}
					numPtr += num3;
				}
			} else {
				for (int j = 0; j < height; j++) {
					int num7 = 0;
					while (num7 < width) {
						complexArray[j, num7].Re = (((0.2125f * numPtr[2]) + (0.7154f * numPtr[1])) + (0.0721f * numPtr[0])) / 255f;
						num7++;
						numPtr += 3;
					}
					numPtr += num3;
				}
			}
			srcImg.UnlockBits(bitmapdata);
			return image;
		}