public GetAlpha32 ( int px, int py, byte &a ) : void | ||
px | int | |
py | int | |
a | byte | |
return | void |
/* * * 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(); }
/* * * 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(); }
/* 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(); }
/* 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(); }