Ejemplo n.º 1
0
	Bitmap* SoftGlow::Process2(const Bitmap* src, int radius, float sharpness, float brightness)
	{
		assert(src && src->IsValid());

		Bitmap* dst = new Bitmap(src->Width(), src->Height(), src->biBitCount, 0, false);
		assert(dst);
		//calc sharpness and brightness
		for (int y = 0; y < src->Height(); y++)
		{
			uint8* p0 = src->Get(0, y);
			uint8* p1 = dst->Get(0, y);

			for (int x = 0; x < src->Width(); x++)
			{
				*(p1 + 0) = (uint8)CalcSharpAndBright(*(p0 + 0), sharpness, brightness);
				*(p1 + 1) = (uint8)CalcSharpAndBright(*(p0 + 1), sharpness, brightness);
				*(p1 + 2) = (uint8)CalcSharpAndBright(*(p0 + 2), sharpness, brightness);

				p0 += src->PixelBytes();
				p1 += dst->PixelBytes();
			}
		}
		//gaussion filter
		Gaussion(dst, (float)radius);

#ifdef _DEBUG
		dst->Save("f:\\tmp0.bmp");
#endif
		int temp;
		for (int y = 0; y < src->Height(); y++)
		{
			uint8* p0 = src->Get(0, y);
			uint8* p1 = dst->Get(0, y);

			for (int x = 0; x < src->Width(); x++)
			{
				//screen op
				*(p1 + 0) = 255 - INT_MULT((255 - *(p0 + 0)), (255 - *(p1 + 0)), temp);
				*(p1 + 1) = 255 - INT_MULT((255 - *(p0 + 1)), (255 - *(p1 + 1)), temp);
				*(p1 + 2) = 255 - INT_MULT((255 - *(p0 + 2)), (255 - *(p1 + 2)), temp);

				p0 += src->PixelBytes();
				p1 += dst->PixelBytes();
			}
		}

		return dst;
	}
Ejemplo n.º 2
0
	Bitmap* SoftGlow::Process1(const Bitmap* src, int radius, float sharpness, float brightness)
	{
		assert(src && src->IsValid());

		int width = src->Width();
		int height = src->Height();

		Bitmap* tmp = new Bitmap(width, height, 8);
		assert(tmp);

		for (int y = 0; y < height; y++)
		{
			uint8* p0 = src->Get(0, y);
			uint8* p1 = tmp->Get(0, y);

			for (int x = 0; x < width; x++)
			{
				uint8 b = *(p0 + 0);
				uint8 g = *(p0 + 1);
				uint8 r = *(p0 + 2);

				*p1 = (uint8)rgb_to_l(r, g, b);

				*p1 = (uint8)CalcSharpAndBright(*p1, sharpness, brightness);

				p0 += src->PixelBytes();
				p1 += tmp->PixelBytes();
			}
		}

		Gaussion(tmp, (float)radius);

#ifdef _DEBUG
		tmp->Save("f:\\tmp0.bmp");
#endif
		Bitmap* dst = new Bitmap(src->Width(), src->Height(), src->biBitCount);
		assert(dst);
		int temp;
		for (int y = 0; y < height; y++)
		{
			uint8* p0 = src->Get(0, y);
			uint8* p1 = tmp->Get(0, y);
			uint8* p2 = dst->Get(0, y);

			for (int x = 0; x < width; x++)
			{
				//screen op
				*(p2 + 0) = 255 - INT_MULT((255 - *(p0 + 0)), (255 - *p1), temp);
				*(p2 + 1) = 255 - INT_MULT((255 - *(p0 + 1)), (255 - *p1), temp);
				*(p2 + 2) = 255 - INT_MULT((255 - *(p0 + 2)), (255 - *p1), temp);

				p0 += src->PixelBytes();
				p1 += tmp->PixelBytes();
				p2 += dst->PixelBytes();
			}
		}

		delete tmp;

		return dst;
	}