rem: int width  = rc->right  - rc->left + 1; int height = rc->bottom - rc->top  + 1; int delta  = a_bitmap->BytesPerRow();  int left   = width; int right  = 0; int top    = 0; int bottom = 0;  PFN_GET_VALID_LINE get_valid_line;  switch (a_bitmap->ColorSpace()) { case B_RGB32: case B_RGB32_BIG: get_valid_line = get_valid_line_RGB32; break; default: return false; break; };  int i = 0; uchar *ptr = (uchar *)a_bitmap->Bits();  while (i < height) { if (get_valid_line(ptr, width, &left, &right)) { top = i; break; } ptr += delta; i++; }  if (i == height) { return false; }  int j = height - 1; ptr = (uchar *)a_bitmap->Bits() + (height - 1) * delta; bool found_boundary = false;  while (j >= i) { if (get_valid_line(ptr, width, &left, &right)) { if (!found_boundary) { bottom = j; found_boundary = true; } } ptr -= delta; j--; }  rc->left   = left; rc->top    = top; rc->right  = right; rc->bottom = bottom;  return true;
add: BoundsCalculator calculator; return calculator.getValidRect(a_bitmap, rc);
context: bool get_valid_rect(BBitmap *a_bitmap, RECT *rc){	int width  = rc->right  - rc->left + 1;	int height = rc->bottom - rc->top  + 1;	int delta  = a_bitmap->BytesPerRow();	int left   = width;	int right  = 0;	int top    = 0;	int bottom = 0;	PFN_GET_VALID_LINE get_valid_line;	switch (a_bitmap->ColorSpace()) {	case B_RGB32:	case B_RGB32_BIG:		get_valid_line = get_valid_line_RGB32;		break;	default:		return false;		break;	};	int i = 0;	uchar *ptr = (uchar *)a_bitmap->Bits();	while (i < height) {		if (get_valid_line(ptr, width, &left, &right)) {			top = i;			break;		}		ptr += delta;		i++;	}	if (i == height) {		return false;	}	int j = height - 1;	ptr = (uchar *)a_bitmap->Bits() + (height - 1) * delta;	bool found_boundary = false;	while (j >= i) {		if (get_valid_line(ptr, width, &left, &right)) {			if (!found_boundary) {				bottom = j;				found_boundary = true;			}		}		ptr -= delta;		j--;	}	rc->left   = left;	rc->top    = top;	rc->right  = right;	rc->bottom = bottom;	return true;}