 
			
				20.09.2009, 17:21
			
			
			
		  
	 | 
	
		
		
		
			  | 
			
			
				
				
				 Начинающий 
				
				
			 | 
			  | 
			
				
				
					Регистрация: 13.12.2008 
					Адрес: Туапсе 
					
					Сообщения: 161
 
				
					Репутация: 20 
					    
				 
				
			 | 
		 
		 
		
	 | 
	
	
	
		
			
			
				 
				
			 
			 
			
		
		
		
		Вот: 
	Код: 
	procedure DrawBitmaptRect(dc : hdc; bmp : HBITMAP; Rect : TRect);
var
  cdc : HDC;
  bInfo : TBitmapInfo;
  prevSetStretchBltMode : Integer;
  dx, dy, dr : Double;
  BitmapCx, BitmapCy : Integer;
  ClipCx, ClipCy : Integer;
  OffsX, OffxY : Integer; 
begin
  cdc := CreateCompatibleDC(dc);
  SelectObject(cdc, bmp);
  GetObject(bmp, SizeOf(bInfo), @Binfo);
  ClipCx := Rect.Right - Rect.Left;
  ClipCy := Rect.Bottom - Rect.Top;
  OffsX := Rect.Left;
  OffxY := Rect.Top;
  BitmapCx := Binfo.bmiHeader.biWidth;
  BitmapCy := bInfo.bmiHeader.biHeight;
  //Считаем оптимальный размер
  if (BitmapCx > ClipCx)or(BitmapCy > ClipCy) then
  begin
    dx := ClipCx / BitmapCx;
    dy := ClipCy / BitmapCy;
    //dr := min(dx, dy);
    if dx < dy then dr := dx else dr := dy;
    Rect.Right := Trunc(BitmapCx * dr);
    Rect.Bottom := Trunc(BitmapCY * dr);
  end
    else
  begin
    Rect.Right := BitmapCx;
    Rect.Bottom := BitmapCy;
  end;
  //Центрируес
  Rect.Left := (ClipCx - Rect.Right) div 2;
  Rect.Top := (ClipCy - Rect.Bottom) div 2;
  OffsetRect(Rect, OffsX, OffxY);
  //Рисуем со сглаживанием
  prevSetStretchBltMode := SetStretchBltMode(dc, HALFTONE);
  with Rect do
    StretchBlt(dc,
      Left, Top, Right - OffsX, Bottom - OffxY,
      cdc,
      0, 0, BitmapCx, BitmapCy,
      SRCCOPY);
    SetStretchBltMode(dc, prevSetStretchBltMode);
  DeleteDC(cdc);
end; 
 
Рисуй так
 
	Код: 
	DrawBitmaptRect(Canvas.Handle, Bitmap.Handle, GetClientRect);  
  
		
	
		
		
		
		
			
		
		
		
		
	
		
		
	
	
	 |