Q&A

  • 이미지 콘트롤안에 비트맵이미지를 패턴화 시키러면?
이미지 컨트롤에 작은 비트맵 이미지를 패턴화 시키고 싶습니다. 알려주세영~

1  COMMENTS
  • Profile
    홍성락 2001.09.09 03:55
    데니 wrote:

    > 이미지 컨트롤에 작은 비트맵 이미지를 패턴화 시키고 싶습니다. 알려주세영~

    ///////////////////////////////////////////////////////////////////////////

    패턴이라는 의미를 잘 이해 못해서요 4가지 예로 들겠습니다.

    ---------------------------------------------------------------------

    1.한이미지를 중앙으로하기

    procedure TForm1.Button1Click(Sender: TObject);

    var

    BitMap : TBitmap;

    BMPFileName : string;

    BMPRect, imageRect : TRect;

    begin

    BMPFileName := 'D:참고자료아이콘아이콘모음아이콘정리건물건물.bmp';



    BitMap := TBitmap.Create;

    BitMap.LoadFromFile(BMPFileName);

    BMPRect := BitMap.Canvas.ClipRect;



    imageRect.Top := Round(image1.Height/2 - BitMap.Height/2);

    imageRect.Left := Round(image1.Width/2 - BitMap.Width/2);

    imageRect.Right := imageRect.Left + BitMap.Width;

    imageRect.Bottom := imageRect.Top + BitMap.Height;



    image1.Canvas.CopyRect(imageRect, BitMap.Canvas , BMPRect);



    end;

    ---------------------------------------------------------------

    2.전체크기로하기

    imageRect := image1.Canvas.ClipRect;

    BMPRect := BitMap.Canvas.ClipRect;

    image1.Canvas.CopyRect(imageRect, BitMap.Canvas , BMPRect);

    ----------------------------------------------------------------

    3.한화면으로 타일

    아래 4번중 BMPFileName을 일반 스트링으로하여 변형하시면됩니다.

    ----------------------------------------------------------------

    4.여러 작은 이미지를 타일처럼 하는방법

    procedure TForm1.BitBtn1Click(Sender: TObject);

    var

    BitMap : TBitmap;

    BMPFileName : Array[1..20] of string;

    i : integer;

    BMPRect, imageRect : TRect;

    TopPoint, MaxTOP : integer;

    begin

    BMPFileName[1] := 'D:참고자료아이콘아이콘모음아이콘정리건물건물.bmp';

    ................

    ................

    BMPFileName[20] := 'D:참고자료아이콘아이콘모음아이콘정리건물FIRE.BMP';



    BitMap := TBitmap.Create;

    imageRect := Rect(0,0,0,0);

    TopPoint := 0;

    MaxTOP := 0;

    for i := 1 to 20 do begin

    BitMap.LoadFromFile(BMPFileName[i]);

    BMPRect := BitMap.Canvas.ClipRect;

    imageRect.Left := imageRect.Right;

    //이미지 컨트 너비롤 초가할때

    if (image1.Width <= (imageRect.Left+BitMap.Width)) then begin

    imageRect.Left := 0;

    imageRect.Right:= 0;

    TopPoint := TopPoint + MaxTOP;

    MaxTOP := 0;

    end;



    imageRect.Top := TopPoint;

    imageRect.Right := imageRect.Right + BMPRect.Right;

    imageRect.Bottom := TopPoint + BMPRect.Bottom;

    //한라인의 이미지중 제일 높은것

    if MaxTOP < BMPRect.Bottom then MaxTOP := BMPRect.Bottom;



    image1.Canvas.CopyRect(imageRect, BitMap.Canvas , BMPRect);

    end;

    end;