コード例 #1
0
        // метод, устанавливающий соответствующий цвет пикселю согласно координатам
        public void SetPixelData(int x, int y, PixelData p)
        {
            PixelData *data = this[x, y];

            data->R = p.R;
            data->G = p.G;
            data->B = p.B;
        }
コード例 #2
0
 public void SetPixel(int x, int y, PixelData colour)
 {
     if (Valid(x, y))
     {
         PixelData *pixel = PixelAt(x, y);
         *          pixel = colour;
     }
 }
コード例 #3
0
        public Pixel GetPixelPos(int x, int y)
        {
            pixelData = (PixelData*)(pBase + y * width + x * sizeof(PixelData));

            Color c =  Color.FromArgb(pixelData->alpha, pixelData->red, pixelData->green, pixelData->blue);
            Pixel p = new Pixel(x,y,c);
            return p;
        }
コード例 #4
0
ファイル: FastBitmap.cs プロジェクト: segrived/ImageEditor
 public int GetPixelInt(int x, int y)
 {
     pixelData = (PixelData*)(pBase + y * width + x * sizeof(PixelData));
     int rgb = pixelData->red;
     rgb = (rgb << 8) + pixelData->green;
     rgb = (rgb << 8) + pixelData->blue;
     return rgb;
 }
コード例 #5
0
        // метод, устанавливающий соответствующий цвет пикселю согласно координатам
        public void SetColor(int x, int y, Color c)
        {
            PixelData *data = this[x, y];

            data->R = c.R;
            data->G = c.G;
            data->B = c.B;
        }
コード例 #6
0
        public void SetPixel(int x, int y, Color color)
        {
            PixelData *data = (PixelData *)(Pointer + (y * mWidth) + (x * sizeof(PixelData)));

            data->alpha = color.A;
            data->red   = color.R;
            data->green = color.G;
            data->blue  = color.B;
        }
コード例 #7
0
        public Pixel GetPixelPos(int x, int y)
        {
            pixelData = (PixelData *)(pBase + y * width + x * sizeof(PixelData));

            Color c = Color.FromArgb(pixelData->alpha, pixelData->red, pixelData->green, pixelData->blue);
            Pixel p = new Pixel(x, y, c);

            return(p);
        }
コード例 #8
0
ファイル: FastBitmap.cs プロジェクト: slagusev/spherestudio
        private void ToGray(int x, int y)
        {
            PixelData *pixel = (PixelData *)(_pBase + y * _width + x * sizeof(PixelData));
            byte       value = (byte)((int)(pixel->r + pixel->g + pixel->b) / 3);

            pixel->r = value;
            pixel->g = value;
            pixel->b = value;
        }
コード例 #9
0
        /// <summary>
        /// Compute the normalisation operation of image
        /// </summary>
        /// <param name="img"></param>
        /// <returns></returns>
        public Bitmap Normalise(double[,] img)
        {
            int    nfil = img.GetLength(0);
            int    ncol = img.GetLength(1);
            double min = 0, max = 0;
            bool   first = true;

            //Computing min and max
            for (int j = 0; j < ncol; j++)
            {
                for (int i = 0; i < nfil; i++)
                {
                    if (first)
                    {
                        min = max = img[i, j]; first = false;
                    }
                    else
                    {
                        if (img[i, j] < min)
                        {
                            min = img[i, j];
                        }
                        else
                        if (img[i, j] > max)
                        {
                            max = img[i, j];
                        }
                    }
                }
            }

            Bitmap = new Bitmap(nfil, ncol, PixelFormat.Format8bppIndexed);
            //Setting color palette
            ColorPalette palette = Bitmap.Palette;

            for (int i = 0; i < 256; i++)
            {
                palette.Entries[i] = Color.FromArgb(i, i, i);
            }
            Bitmap.Palette = palette;

            //Normalising
            LockBitmap();
            double k = 255 / (max - min);

            for (int y = 0; y < ncol; y++)
            {
                PixelData *pPixel = PixelAt(0, y);
                for (int x = 0; x < nfil; x++)
                {
                    pPixel->gray = Convert.ToByte(k * (img[x, y] - min));
                    pPixel++;
                }
            }
            UnlockBitmap();
            return(Bitmap);
        }
コード例 #10
0
        unsafe int DoStuff()
        {
            IntPtr     pBase = Marshal.AllocCoTaskMem(0x40000 * 3);
            PixelData *foo   = (PixelData *)(pBase + 511 * (512 * sizeof(PixelData)) + 511 * sizeof(PixelData));

            CheckPointer(*foo);

            return(0);
        }
コード例 #11
0
 /// <summary>
 /// Start at the beginning of the bitmap
 /// </summary>
 public void InitCurrentPixel()
 {
     LockBitmap();
     //if (pBase == null)
     //{
     //		throw new InvalidOperationException("Bitmap must be locked before calling InitCurrentPixel()");
     //		}
     pCurrentPixel = (PixelData *)pBase;
 }
コード例 #12
0
        public void SetPixel(int x, int y, Color color)
        {
            PixelData *data = (PixelData *)(pBase + y * width + x * sizeof(PixelData));

            data->alpha = color.A;
            data->green = color.G;
            data->blue  = color.B;
            data->red   = color.R;
        }
コード例 #13
0
        public unsafe void SetPixel(int x, int y, Color color)
        {
            PixelData *dataPtr = (PixelData *)((this.pBase + (y * this.width)) + (x * sizeof(PixelData)));

            dataPtr->alpha = color.A;
            dataPtr->red   = color.R;
            dataPtr->green = color.G;
            dataPtr->blue  = color.B;
        }
コード例 #14
0
ファイル: FastBitmap.cs プロジェクト: faorg/wwt-website
 public FastBitmapEnumerator(FastBitmap fastBitmap)
 {
     fastBitmap.LockBitmap();
     locked = true;
     this.fastBitmap = fastBitmap;
     x = -1;
     y = 0;
     pCurrentPixel = fastBitmap[x, y];
 }
コード例 #15
0
        public unsafe override void Filter(int x, int y, PixelGet getPixel, PixelData *pPixel, int x0, int y0, int x1, int y1)
        {
            double mask;
            int    max_diff, max_temp;
            var    ratio = this.Threshold / 100.0;

            var pPixels = new[]
            {
                getPixel(x - 1, y + 1),
                getPixel(x, y + 1),
                getPixel(x + 1, y + 1),
                getPixel(x - 1, y),
                getPixel(x + 1, y),
                getPixel(x - 1, y - 1),
                getPixel(x, y - 1),
                getPixel(x + 1, y - 1)
            };

            ///Red
            max_diff = 0;
            foreach (var pCurrent in pPixels)
            {
                max_temp = Math.Abs(pCurrent->red - pPixel->red);
                if (max_temp > max_diff)
                {
                    max_diff = max_temp;
                }
            }
            mask         = 1.0 / (max_diff / Math.Sqrt(pPixel->red + 1.0) / 3.0 + 1.0);
            pPixel->red += (byte)(ratio * ((255 - pPixel->red) * mask - max_diff * pPixel->red / 100.0));

            ///Green
            max_diff = 0;
            foreach (var pCurrent in pPixels)
            {
                max_temp = Math.Abs(pCurrent->green - pPixel->green);
                if (max_temp > max_diff)
                {
                    max_diff = max_temp;
                }
            }
            mask           = 1.0 / (max_diff / Math.Sqrt(pPixel->green + 1.0) / 3.0 + 1.0);
            pPixel->green += (byte)(ratio * ((255 - pPixel->green) * mask - max_diff * pPixel->green / 100.0));

            ///Blue
            max_diff = 0;
            foreach (var pCurrent in pPixels)
            {
                max_temp = Math.Abs(pCurrent->blue - pPixel->blue);
                if (max_temp > max_diff)
                {
                    max_diff = max_temp;
                }
            }
            mask          = 1.0 / (max_diff / Math.Sqrt(pPixel->blue + 1.0) / 3.0 + 1.0);
            pPixel->blue += (byte)(ratio * ((255 - pPixel->blue) * mask - max_diff * pPixel->blue / 100.0));
        }
コード例 #16
0
 public FastBitmapEnumerator(FastBitmap fastBitmap)
 {
     fastBitmap.LockBitmap();
     locked          = true;
     this.fastBitmap = fastBitmap;
     x             = -1;
     y             = 0;
     pCurrentPixel = fastBitmap[x, y];
 }
コード例 #17
0
        public void SetPixel(int x, int y, Color color)
        {
            PixelData *data = (PixelData *)(StartByte + y * PictureWidth + x * sizeof(PixelData));

            data->Alpha = color.A;
            data->Red   = color.R;
            data->Green = color.G;
            data->Blue  = color.B;
        }
コード例 #18
0
        public void SetPixel(int x, int y, Color color)
        {
            PixelData *p = this.PixelAt(x, y);

            p->alpha = color.A;
            p->red   = color.R;
            p->green = color.G;
            p->blue  = color.B;
        }
コード例 #19
0
        public void SetPixel(int x, int y, byte val)
        {
            PixelData *data = (PixelData *)(pBase + y * width + x * sizeof(PixelData));

            data->alpha = 255;
            data->red   = val;
            data->green = val;
            data->blue  = val;
        }
コード例 #20
0
ファイル: HistogramRetriever.cs プロジェクト: damolinx/ima
        public unsafe override void Filter(PixelData *pPixel)
        {
            byte gray = (byte)(0.299 * pPixel->red + 0.587 * pPixel->green + 0.114 * pPixel->blue);

            this.red[pPixel->red]++;
            this.green[pPixel->green]++;
            this.blue[pPixel->blue]++;
            this.gray[gray]++;
        }
コード例 #21
0
        public void setPixel(int x, int y, long color)
        {
            PixelData *p = PixelAt(x, y);

            p->alpha = 0xFF; //(byte)((color >> 24) & 0xFF);
            p->red   = (byte)((color >> 16) & 0xFF);
            p->green = (byte)((color >> 8) & 0xFF);
            p->blue  = (byte)(color & 0xFF);
        }
コード例 #22
0
        internal unsafe PixelData *GetPixelDataAt(BitmapData data,
                                                  int x, int y, int scanWidth)
        {
            PixelData *result = (PixelData *)
                                ((byte *)data.Scan0.ToPointer() + y * scanWidth);

            result += x;
            return(result);
        }
コード例 #23
0
ファイル: FastImage.cs プロジェクト: MicusanL/AVQ
 public void SetPixel(int col, int row, Color color)
 {
     unsafe
     {
         PixelData *pPixel = pBase + row * Width + col;
         pPixel->red   = color.R;
         pPixel->green = color.G;
         pPixel->blue  = color.B;
     }
 }
コード例 #24
0
 public int GetPixel(int col, int row)
 {
     unsafe
     {
         PixelData *pBase  = (PixelData *)bitmapData.Scan0;
         PixelData *pPixel = pBase + row * currentBitmapWidth + col;
         color = (int)(pPixel->red + pPixel->green + pPixel->blue) / 3;
     }
     return(color);
 }
コード例 #25
0
ファイル: FastBitmap.cs プロジェクト: segrived/ImageEditor
 public Color GetPixel(int x, int y)
 {
     pixelData = (PixelData*)(pBase + y * width + x * sizeof(PixelData));
     return Color.FromArgb(
         pixelData->alpha,
         pixelData->red,
         pixelData->green,
         pixelData->blue
     );
 }
コード例 #26
0
 public Color GetPixel(int col, int row)
 {
     unsafe
     {
         PixelData *pBase  = (PixelData *)bitmapData.Scan0;
         PixelData *pPixel = pBase + row * currentBitmapWidth + col;
         color = Color.FromArgb(pPixel->red, pPixel->green, pPixel->blue);
     }
     return(color);
 }
コード例 #27
0
        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal methods.

        internal unsafe static float GetSquareLinearDistance(
            PixelData *pixel, PixelData *otherPixel)
        {
            float deltaR = pixel->red - otherPixel->red;
            float deltaG = pixel->green - otherPixel->green;
            float deltaB = pixel->blue - otherPixel->blue;

            deltaR *= deltaR; deltaG *= deltaG; deltaB *= deltaB;
            return(deltaR + deltaG + deltaB);
        }
コード例 #28
0
        /// <summary>Hide an Int32 value in pPixel an the following pixels</summary>
        /// <param name="secretValue">The value to hide</param>
        /// <param name="pPixel">The first pixel to use</param>
        private unsafe void HideInt32(Int32 secretValue, ref PixelData *pPixel)
        {
            byte secretByte;

            for (int byteIndex = 0; byteIndex < 4; byteIndex++)
            {
                secretByte = (byte)(secretValue >> (8 * byteIndex));
                HideByte(secretByte, ref pPixel);
            }
        }
コード例 #29
0
        private Bitmap GetBitmapInt(double min, double max, ScaleMap scale)
        {
            int[]      buf     = (int[])DataBuffer;
            double     factor  = max - min;
            int        stride  = AxisSize[0];
            int        page    = AxisSize[0] * AxisSize[1];
            Bitmap     bmp     = new Bitmap(AxisSize[0], AxisSize[1]);
            FastBitmap fastBmp = new FastBitmap(bmp);

            fastBmp.LockBitmap();
            unsafe
            {
                for (int y = 0; y < AxisSize[1]; y++)
                {
                    int        indexY = ((AxisSize[1] - 1) - y);
                    PixelData *pData  = fastBmp[0, y];
                    for (int x = 0; x < AxisSize[0]; x++)
                    {
                        if (color)
                        {
                            int datR = buf[(x + indexY * stride)];
                            int datG = buf[(x + indexY * stride) + page];
                            int datB = buf[(x + indexY * stride) + page * 2];
                            if (ContainsBlanks && (double)datR == BlankValue)
                            {
                                *pData++ = new PixelData(0, 0, 0, 0);
                            }
                            else
                            {
                                int r       = scale.Map(datR);
                                int g       = scale.Map(datG);
                                int b       = scale.Map(datB);
                                *   pData++ = new PixelData(r, g, b, 255);
                            }
                        }
                        else
                        {
                            int dataValue = buf[x + indexY * stride];
                            if (ContainsBlanks && (double)dataValue == BlankValue)
                            {
                                *pData++ = new PixelData(0, 0, 0, 0);
                            }
                            else
                            {
                                Byte val     = scale.Map(dataValue);
                                *    pData++ = new PixelData(val, val, val, 255);
                            }
                        }
                    }
                }
            }
            fastBmp.UnlockBitmap();

            return(bmp);
        }
コード例 #30
0
 public void SetPixel(Point point, Color c)
 {
     unsafe
     {
         PixelData *pBase  = (PixelData *)bitmapData.Scan0;
         PixelData *pPixel = pBase + point.Y * currentBitmapWidth + point.X;
         pPixel->red   = c.R;
         pPixel->green = c.G;
         pPixel->blue  = c.B;
     }
 }
コード例 #31
0
        public Color GetPixel(Point point)
        {
            unsafe
            {
                PixelData *pBase  = (PixelData *)shadowCopybitmapData.Scan0;
                PixelData *pPixel = pBase + point.Y * currentBitmapWidth + point.X;
                color = Color.FromArgb(pPixel->red, pPixel->green, pPixel->blue);
            }

            return(color);
        }
コード例 #32
0
ファイル: PixelFilters.cs プロジェクト: damolinx/ima
        public unsafe override void Filter(int x, int y, PixelGet getPixel, PixelData *pPixel, int x0, int y0, int x1, int y1)
        {
            var pPixel1 = getPixel(x, y + 1);
            var pPixel2 = getPixel(x - 1, y);
            var pPixel3 = getPixel(x + 1, y);
            var pPixel4 = getPixel(x, y - 1);

            pPixel->red   = (byte)MathEx.Clamp((pPixel1->red + pPixel2->red + pPixel3->red + pPixel4->red + pPixel->red) / 5.0, 0, 255);
            pPixel->green = (byte)MathEx.Clamp((pPixel1->green + pPixel2->green + pPixel3->green + pPixel4->green + pPixel->green) / 5.0, 0, 255);
            pPixel->blue  = (byte)MathEx.Clamp((pPixel1->blue + pPixel2->blue + pPixel3->blue + pPixel4->blue + pPixel->blue) / 5.0, 0, 255);
        }
コード例 #33
0
 public void SetPixel(int col, int row, Color c)
 {
     unsafe
     {
         PixelData *pBase  = (PixelData *)bitmapData.Scan0;
         PixelData *pPixel = pBase + row * currentBitmapWidth + col;
         pPixel->red   = c.R;
         pPixel->green = c.G;
         pPixel->blue  = c.B;
     }
 }
コード例 #34
0
 public Color GetPixel(int X, int Y)
 {
     try {
         PixelData *p = PixelAt(X, Y);
         return(Color.FromArgb((int)p->red, (int)p->green, (int)p->blue));
     } catch (AccessViolationException ave) {
         throw (ave);
     } catch (Exception ex) {
         throw ex;
     }
 }
コード例 #35
0
ファイル: FastBitmap.cs プロジェクト: Radnen/spherestudio
        /// <summary>
        /// Gets a pixel at the x/y location.
        /// </summary>
        /// <param name="x">The x pixel location.</param>
        /// <param name="y">The y pixel location.</param>
        /// <returns>The Color at the x/y location.</returns>
        /// <exception cref="Exception">Invalid color format.</exception>
        public Color GetPixel(int x, int y)
        {
            _pixelData = (PixelData*)(_pBase + y * _width + x * sizeof(PixelData));

            switch (_cFormat)
            {
                case ColorFormat.FormatABGR:
                    return Color.FromArgb(_pixelData->a, _pixelData->b, _pixelData->g, _pixelData->r);
                case ColorFormat.FormatARGB:
                    return Color.FromArgb(_pixelData->a, _pixelData->r, _pixelData->g, _pixelData->b);
                case ColorFormat.FormatBGRA:
                    return Color.FromArgb(_pixelData->b, _pixelData->g, _pixelData->r, _pixelData->a);
                case ColorFormat.FormatRGBA:
                    return Color.FromArgb(_pixelData->r, _pixelData->g, _pixelData->b, _pixelData->a);
            }

            throw new Exception("Invalid color format.");
        }
コード例 #36
0
ファイル: FastBitmap.cs プロジェクト: faorg/wwt-website
 public bool MoveNext()
 {
     x++;
     pCurrentPixel++;
     if (x == fastBitmap.Size.X)
     {
         y++;
         if (y == fastBitmap.Size.Y)
         {
             return false;
         }
         else
         {
             x = 0;
             pCurrentPixel = fastBitmap[0, y];
             //Debug.WriteLine(String.Format("{0}", pCurrentPixel - fastBitmap[0, 0]));
         }
     }
     return true;
 }
コード例 #37
0
 public Color GetPixel(int x, int y)
 {
     _pixelData = (PixelData*)(_pBase + y * _width + x * sizeof(PixelData));
     return Color.FromArgb(_pixelData->Alpha, _pixelData->Red, _pixelData->Green, _pixelData->Blue);
 }
コード例 #38
0
 /// <summary>
 /// Start at the beginning of the bitmap
 /// </summary>
 public void InitCurrentPixel()
 {
     LockBitmap();
     pCurrentPixel = (PixelData*)pBase;
 }
コード例 #39
0
ファイル: FastBitmap.cs プロジェクト: faorg/wwt-website
 /// <summary>
 /// Start at the beginning of the bitmap
 /// </summary>
 public void InitCurrentPixel()
 {
     LockBitmap();
     //if (pBase == null)
     //{
     //		throw new InvalidOperationException("Bitmap must be locked before calling InitCurrentPixel()");
     //		}
     pCurrentPixel = (PixelData*)pBase;
 }
コード例 #40
0
ファイル: FastBitmap.cs プロジェクト: faorg/wwt-website
 /// <summary>
 /// Return the next pixel
 /// </summary>
 /// <returns>The next pixel, or null if done</returns>
 public PixelData* GetNextPixel()
 {
     PixelData* pReturnPixel = pCurrentPixel;
     if (xLocation == size.X)
     {
         xLocation = 0;
         yLocation++;
         if (yLocation == size.Y)
         {
             UnlockBitmap();
             return null;
         }
         else
         {
             pCurrentPixel = this[0, yLocation];
         }
     }
     else
     {
         xLocation++;
         pCurrentPixel++;
     }
     return pReturnPixel;
 }
コード例 #41
0
ファイル: BmpData.cs プロジェクト: juliobbv/CsJpgDec
 internal Color2 GetPixel(int x, int y)
 {
     pixelData = (PixelData*)(pBase + y * stride + x * sizeof(PixelData));
     return new Color2() { a = pixelData->alpha, r = pixelData->red, g = pixelData->green, b = pixelData->blue };
 }
コード例 #42
0
ファイル: FastBitmap.cs プロジェクト: GodLesZ/svn-dump
		public Color GetPixel(int x, int y) {
			mCurrentPixelData = (PixelData*)(Pointer + y * mWidth + x * sizeof(PixelData));
			return Color.FromArgb(mCurrentPixelData->alpha, mCurrentPixelData->red, mCurrentPixelData->green, mCurrentPixelData->blue);
		}
コード例 #43
0
ファイル: FastBitmap.cs プロジェクト: kalimaul/specalg
 public PixelData* GetPixelData(int x, int y)
 {
     pixelData = (PixelData*)(pBase + y * width + x * sizeof(PixelData));
     return pixelData;
 }
コード例 #44
0
ファイル: FastBitmap.cs プロジェクト: kalimaul/specalg
 public void CopyFrom(int x, int y, PixelData* other)
 {
     pixelData = (PixelData*)(pBase + y * width + x * sizeof(PixelData));
     *pixelData = *other;
 }
コード例 #45
0
 public int GetPixel(int x, int y)
 {
     pixelData = (PixelData*)(pBase + y * width + x * sizeof(PixelData));
     return (int)MakeArgb(pixelData->alpha, pixelData->red, pixelData->green, pixelData->blue);
 }
コード例 #46
0
ファイル: FastBitmap.cs プロジェクト: makht/PicMaster
 private void InitCurrentPixel()
 {
     _pInitPixel = (PixelData*)_pBase;
 }
コード例 #47
0
 /// <summary>
 /// The get pixel.
 /// </summary>
 /// <param name="x">
 /// The x.
 /// </param>
 /// <param name="y">
 /// The y.
 /// </param>
 /// <returns>
 /// The <see cref="Color"/>.
 /// </returns>
 public Color GetPixel(int x, int y)
 {
     this._pixelData = (PixelData*)(this._pBase + y * this._width + x * sizeof(PixelData));
     return Color.FromArgb(this._pixelData->Alpha, this._pixelData->Red, this._pixelData->Green, this._pixelData->Blue);
 }