Free() public method

public Free ( ) : void
return void
Example #1
0
        public TexturePage(string filePath)
        {
            var bitmap = new QBitmap(filePath);

            CreateTexture(bitmap.BitmapData);
            bitmap.Free();
        }
Example #2
0
        /*
         *
         * public void Blur(int radius, int passes)
         * {
         *  QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));
         *
         *  byte r=0,g=0,b=0,a=0;
         *  int summedR, summedG, summedB, summedA;
         *  int weight = 0;
         *  int xpos, ypos, x, y, kx, ky;
         *
         *
         *  for (int pass = 0; pass < passes; pass++)
         *  {
         *
         *      //horizontal pass
         *      for (y = 0; y < bitmap.Height; y++)
         *      {
         *          for (x = 0; x < bitmap.Width; x++)
         *          {
         *              summedR = summedG = summedB = summedA = weight = 0;
         *              for (kx = -radius; kx <= radius; kx++)
         *              {
         *                  xpos = x + kx;
         *                  if (xpos >= 0 && xpos < bitmap.Width)
         *                  {
         *                      GetPixel32(xpos, y, ref r, ref g, ref b, ref a);
         *
         *
         *                      summedR += r;
         *                      summedG += g;
         *                      summedB += b;
         *                      summedA += a;
         *                      weight++;
         *                  }
         *
         *              }
         *
         *              summedR /= weight;
         *              summedG /= weight;
         *              summedB /= weight;
         *              summedA /= weight;
         *
         *              tmp.PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);
         *          }
         *      }
         *
         *
         *
         *
         *      //vertical pass
         *      for (x = 0; x < bitmap.Width; ++x)
         *      {
         *          for (y = 0; y < bitmap.Height; ++y)
         *          {
         *              summedR = summedG = summedB = summedA = weight = 0;
         *              for (ky = -radius; ky <= radius; ky++)
         *              {
         *                  ypos = y + ky;
         *                  if (ypos >= 0 && ypos < bitmap.Height)
         *                  {
         *                      tmp.GetPixel32(x, ypos, ref r, ref g, ref b, ref a);
         *
         *                      summedR += r;
         *                      summedG += g;
         *                      summedB += b;
         *                      summedA += a;
         *                      weight++;
         *                  }
         *              }
         *
         *              summedR /= weight;
         *              summedG /= weight;
         *              summedB /= weight;
         *              summedA /= weight;
         *
         *              PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);
         *
         *          }
         *      }
         *
         *  }
         *
         *  tmp.Free();
         *
         * }*/



        public void BlurAlpha(int radius, int passes)
        {
            QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));

            byte a = 0;
            int  summedA;
            int  weight = 0;
            int  xpos, ypos, x, y, kx, ky;
            int  width  = bitmap.Width;
            int  height = bitmap.Height;

            for (int pass = 0; pass < passes; pass++)
            {
                //horizontal pass
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        summedA = weight = 0;
                        for (kx = -radius; kx <= radius; kx++)
                        {
                            xpos = x + kx;
                            if (xpos >= 0 && xpos < width)
                            {
                                GetAlpha32(xpos, y, ref a);
                                summedA += a;
                                weight++;
                            }
                        }

                        summedA /= weight;
                        tmp.PutAlpha32(x, y, (byte)summedA);
                    }
                }



                //vertical pass
                for (x = 0; x < width; ++x)
                {
                    for (y = 0; y < height; ++y)
                    {
                        summedA = weight = 0;
                        for (ky = -radius; ky <= radius; ky++)
                        {
                            ypos = y + ky;
                            if (ypos >= 0 && ypos < height)
                            {
                                tmp.GetAlpha32(x, ypos, ref a);
                                summedA += a;
                                weight++;
                            }
                        }

                        summedA /= weight;

                        PutAlpha32(x, y, (byte)summedA);
                    }
                }
            }

            tmp.Free();
        }
Example #3
0
 public TexturePage(string filePath)
 {
     var bitmap = new QBitmap(filePath);
     CreateTexture(bitmap.bitmapData);
     bitmap.Free();
 }
Example #4
0
        /*

        public void Blur(int radius, int passes)
        {
            QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));

            byte r=0,g=0,b=0,a=0;
            int summedR, summedG, summedB, summedA;
            int weight = 0;
            int xpos, ypos, x, y, kx, ky;


            for (int pass = 0; pass < passes; pass++)
            {

                //horizontal pass
                for (y = 0; y < bitmap.Height; y++)
                {
                    for (x = 0; x < bitmap.Width; x++)
                    {
                        summedR = summedG = summedB = summedA = weight = 0;
                        for (kx = -radius; kx <= radius; kx++)
                        {
                            xpos = x + kx;
                            if (xpos >= 0 && xpos < bitmap.Width)
                            {
                                GetPixel32(xpos, y, ref r, ref g, ref b, ref a);


                                summedR += r;
                                summedG += g;
                                summedB += b;
                                summedA += a;
                                weight++;
                            }

                        }

                        summedR /= weight;
                        summedG /= weight;
                        summedB /= weight;
                        summedA /= weight;

                        tmp.PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);
                    }
                }



                
                //vertical pass
                for (x = 0; x < bitmap.Width; ++x)
                {
                    for (y = 0; y < bitmap.Height; ++y)
                    {
                        summedR = summedG = summedB = summedA = weight = 0;
                        for (ky = -radius; ky <= radius; ky++)
                        {
                            ypos = y + ky;
                            if (ypos >= 0 && ypos < bitmap.Height)
                            {
                                tmp.GetPixel32(x, ypos, ref r, ref g, ref b, ref a);

                                summedR += r;
                                summedG += g;
                                summedB += b;
                                summedA += a;
                                weight++;
                            }
                        }

                        summedR /= weight;
                        summedG /= weight;
                        summedB /= weight;
                        summedA /= weight;

                        PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);

                    }
                } 

            }

            tmp.Free();

        }*/




        public void BlurAlpha(int radius, int passes)
        {
            QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));

            byte a = 0;
            int summedA;
            int weight = 0;
            int xpos, ypos, x, y, kx, ky;
            int width = bitmap.Width;
            int height = bitmap.Height;

            for (int pass = 0; pass < passes; pass++)
            {

                //horizontal pass
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        summedA = weight = 0;
                        for (kx = -radius; kx <= radius; kx++)
                        {
                            xpos = x + kx;
                            if (xpos >= 0 && xpos < width)
                            {
                                GetAlpha32(xpos, y, ref a);
                                summedA += a;
                                weight++;
                            }
                        }

                        summedA /= weight;
                        tmp.PutAlpha32(x, y, (byte)summedA);
                    }
                }




                //vertical pass
                for (x = 0; x <width; ++x)
                {
                    for (y = 0; y < height; ++y)
                    {
                        summedA = weight = 0;
                        for (ky = -radius; ky <= radius; ky++)
                        {
                            ypos = y + ky;
                            if (ypos >= 0 && ypos < height)
                            {
                                tmp.GetAlpha32(x, ypos,ref a);
                                summedA += a;
                                weight++;
                            }
                        }

                        summedA /= weight;

                        PutAlpha32(x, y, (byte)summedA);

                    }
                }

            }

            tmp.Free();

        }
Example #5
0
        /*
         *
         * public void Blur(int radius, int passes)
         * {
         *  QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));
         *
         *  byte r=0,g=0,b=0,a=0;
         *  int summedR, summedG, summedB, summedA;
         *  int weight = 0;
         *  int xpos, ypos, x, y, kx, ky;
         *
         *
         *  for (int pass = 0; pass < passes; pass++)
         *  {
         *
         *      //horizontal pass
         *      for (y = 0; y < bitmap.Height; y++)
         *      {
         *          for (x = 0; x < bitmap.Width; x++)
         *          {
         *              summedR = summedG = summedB = summedA = weight = 0;
         *              for (kx = -radius; kx <= radius; kx++)
         *              {
         *                  xpos = x + kx;
         *                  if (xpos >= 0 && xpos < bitmap.Width)
         *                  {
         *                      GetPixel32(xpos, y, ref r, ref g, ref b, ref a);
         *
         *
         *                      summedR += r;
         *                      summedG += g;
         *                      summedB += b;
         *                      summedA += a;
         *                      weight++;
         *                  }
         *
         *              }
         *
         *              summedR /= weight;
         *              summedG /= weight;
         *              summedB /= weight;
         *              summedA /= weight;
         *
         *              tmp.PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);
         *          }
         *      }
         *
         *
         *
         *
         *      //vertical pass
         *      for (x = 0; x < bitmap.Width; ++x)
         *      {
         *          for (y = 0; y < bitmap.Height; ++y)
         *          {
         *              summedR = summedG = summedB = summedA = weight = 0;
         *              for (ky = -radius; ky <= radius; ky++)
         *              {
         *                  ypos = y + ky;
         *                  if (ypos >= 0 && ypos < bitmap.Height)
         *                  {
         *                      tmp.GetPixel32(x, ypos, ref r, ref g, ref b, ref a);
         *
         *                      summedR += r;
         *                      summedG += g;
         *                      summedB += b;
         *                      summedA += a;
         *                      weight++;
         *                  }
         *              }
         *
         *              summedR /= weight;
         *              summedG /= weight;
         *              summedB /= weight;
         *              summedA /= weight;
         *
         *              PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);
         *
         *          }
         *      }
         *
         *  }
         *
         *  tmp.Free();
         *
         * }*/

        public void ExpandAlpha(int radius, int passes)
        {
            QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));

            byte a = 0;
            byte max;
            int  xpos, ypos, x, y, kx, ky;
            int  width  = bitmap.Width;
            int  height = bitmap.Height;

            for (int pass = 0; pass < passes; pass++)
            {
                //horizontal pass
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        max = 0;
                        for (kx = -radius; kx <= radius; kx++)
                        {
                            xpos = x + kx;
                            if (xpos >= 0 && xpos < width)
                            {
                                GetAlpha32(xpos, y, ref a);
                                if (a > max)
                                {
                                    max = a;
                                }
                            }
                        }

                        tmp.PutAlpha32(x, y, max);
                    }
                }

                //vertical pass
                for (x = 0; x < width; ++x)
                {
                    for (y = 0; y < height; ++y)
                    {
                        max = 0;
                        for (ky = -radius; ky <= radius; ky++)
                        {
                            ypos = y + ky;
                            if (ypos >= 0 && ypos < height)
                            {
                                tmp.GetAlpha32(x, ypos, ref a);
                                if (a > max)
                                {
                                    max = a;
                                }
                            }
                        }

                        PutAlpha32(x, y, max);
                    }
                }
            }

            tmp.Free();
        }
Example #6
0
        /*

        public void Blur(int radius, int passes)
        {
            QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));

            byte r=0,g=0,b=0,a=0;
            int summedR, summedG, summedB, summedA;
            int weight = 0;
            int xpos, ypos, x, y, kx, ky;

            for (int pass = 0; pass < passes; pass++)
            {

                //horizontal pass
                for (y = 0; y < bitmap.Height; y++)
                {
                    for (x = 0; x < bitmap.Width; x++)
                    {
                        summedR = summedG = summedB = summedA = weight = 0;
                        for (kx = -radius; kx <= radius; kx++)
                        {
                            xpos = x + kx;
                            if (xpos >= 0 && xpos < bitmap.Width)
                            {
                                GetPixel32(xpos, y, ref r, ref g, ref b, ref a);

                                summedR += r;
                                summedG += g;
                                summedB += b;
                                summedA += a;
                                weight++;
                            }

                        }

                        summedR /= weight;
                        summedG /= weight;
                        summedB /= weight;
                        summedA /= weight;

                        tmp.PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);
                    }
                }

                //vertical pass
                for (x = 0; x < bitmap.Width; ++x)
                {
                    for (y = 0; y < bitmap.Height; ++y)
                    {
                        summedR = summedG = summedB = summedA = weight = 0;
                        for (ky = -radius; ky <= radius; ky++)
                        {
                            ypos = y + ky;
                            if (ypos >= 0 && ypos < bitmap.Height)
                            {
                                tmp.GetPixel32(x, ypos, ref r, ref g, ref b, ref a);

                                summedR += r;
                                summedG += g;
                                summedB += b;
                                summedA += a;
                                weight++;
                            }
                        }

                        summedR /= weight;
                        summedG /= weight;
                        summedB /= weight;
                        summedA /= weight;

                        PutPixel32(x, y, (byte)summedR, (byte)summedG, (byte)summedB, (byte)summedA);

                    }
                }

            }

            tmp.Free();

        }*/
        public void ExpandAlpha(int radius, int passes)
        {
            QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));

            byte a = 0;
            byte max;
            int xpos, ypos, x, y, kx, ky;
            int width = bitmap.Width;
            int height = bitmap.Height;

            for (int pass = 0; pass < passes; pass++)
            {

                //horizontal pass
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        max = 0;
                        for (kx = -radius; kx <= radius; kx++)
                        {
                            xpos = x + kx;
                            if (xpos >= 0 && xpos < width)
                            {
                                GetAlpha32(xpos, y, ref a);
                                if (a > max)
                                    max = a;
                            }
                        }

                        tmp.PutAlpha32(x, y, max);
                    }
                }

                //vertical pass
                for (x = 0; x < width; ++x)
                {
                    for (y = 0; y < height; ++y)
                    {
                        max = 0;
                        for (ky = -radius; ky <= radius; ky++)
                        {
                            ypos = y + ky;
                            if (ypos >= 0 && ypos < height)
                            {
                                tmp.GetAlpha32(x, ypos, ref a);
                                if (a > max)
                                    max = a;
                            }
                        }

                        PutAlpha32(x, y, max);

                    }
                }

            }

            tmp.Free();
        }