Lazarus (
www.lazarus.freepascal.org/index.php) в руки, итоговую картинку на форму, брать исходную, обрабатывать этой вот процедурой. Смысл, думаю, понятен. Если нужно - могу выложить все исходники. 
Procedure TForm1.StretchFine(inPicture: TPicture; OutImage: TImage);
Var A, B, X, Y, X1, Y1, DX, DY: integer;
  r1, r2            : real;
  StretchFineImage  : TImage;
Begin
  A := OutImage.width;
  B := OutImage.height;
  StretchFineImage := TImage.Create(Nil);
  StretchFineImage.width := a;
  StretchFineImage.height := b;
  StretchFineImage.left := 0;
  StretchFineImage.Top := 0;
  X := InPicture.width;
  Y := InPicture.height;
  R1 := X / Y;                          //соотношение в исходной картинке
  R2 := A / B;                          //   --       в итоговой картинке
  If r1 > r2 Then Begin
    x1 := A;
    y1 := trunc(A / X * Y);
  End Else Begin
    x1 := trunc(B / Y * X);
    y1 := b;
  End;
  Dx := trunc((a - x1) / 2);
  Dy := trunc((b - y1) / 2);
  StretchFineImage.Canvas.Brush.Color := clWhite;
  StretchFineImage.Canvas.FillRect(rect(0, 0, a, b));
  StretchFineImage.Canvas.StretchDraw(rect(Dx, Dy, a - Dx, b - Dy), InPicture.Graphic);
  OutImage.Picture := StretchFineImage.Picture;
  StretchFineImage.Free;
  StretchFineImage := Nil;
End;