示例#1
0
	void SimpleSurface::applyFilter (Surface *inSrc, const Rect &inRect, ImagePoint inOffset, Filter *inFilter) {
		
		if (!mBase) return;
		FilterList f;
		f.push_back (inFilter);
		
		Rect src_rect (inRect.w, inRect.h);
		Rect dest = GetFilteredObjectRect (f, src_rect);
		
		inSrc->IncRef ();
		Surface *result = FilterBitmap (f, inSrc, src_rect, dest, false, ImagePoint (inRect.x, inRect.y));
		
		dest.Translate (inOffset.x, inOffset.y);
		
		src_rect = Rect (0, 0, result->Width (), result->Height ());
		int dx = dest.x;
		int dy = dest.y;
		dest = dest.Intersect (Rect (0, 0, mWidth, mHeight));
		dest.Translate (-dx, -dy);
		dest = dest.Intersect (src_rect);
		dest.Translate (dx, dy);
		
		int bpp = BytesPP ();
		
		RenderTarget t = BeginRender (dest, false);
		//printf("Copy back @ %d,%d %dx%d  + (%d,%d)\n", dest.x, dest.y, t.Width(), t.Height(), dx, dy);
		for (int y = 0; y < t.Height (); y++)
			memcpy ((void *)(t.Row (y + dest.y) + ((dest.x) * bpp)), result->Row (y - dy) - (dx * bpp), dest.w * bpp);
		
		EndRender ();
		
		result->DecRef ();
		
	}