Results 1 to 5 of 5

Thread: Resize Bitmap

  1. #1
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default Resize Bitmap

    Hey.

    I'm trying to resize a bitmap during Runtime, and tried "FastDrawSizeTransparent(0,0,500,500,test,bla) ;" But it doesnt seem to work .

    It should in theory resize test to 500x500 px and write it into bla . But it doesnt work, its only generating weird bitmaps.

    Any other way to "change the dimensions"/resize a bitmap during runtime ?

    ~caused

  2. #2
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    CopyCanvas?

  3. #3
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    // nvm.

    Got it working now *yay*
    Last edited by caused; 09-02-2009 at 08:29 PM.

  4. #4
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    When you use CopyCanvas, you need to use the Canvas for the variables

    SCAR Code:
    program ResizeBitmap;
    const
      InW = 300;
      InH = 300;
      OutW = 100;
      OutH = 100;
    var
      BitmapIn, BitmapOut: Integer;
    begin
      BitmapIn := BitmapFromString(InW, InH, '');
      BitmapOut := BitmapFromString(OutW, OutH, '');
     
      try
        FastDrawClear(BitmapIn, clRed);
        with GetBitmapCanvas(BitmapIn) do
        begin
          Brush.Color := clBlue;
          Rectangle(10, 10, InW - 10, InH - 10);
          Brush.Color := clYellow;
          RoundRect(10, 10, InW - 10, InH - 10, InW * 2 - 20, InH * 2 - 20);
        end;
       
        CopyCanvas(GetBitmapCanvas(BitmapIn), GetBitmapCanvas(BitmapOut), 0, 0, InW, InH, 0, 0, OutW, OutH);
       
        WriteLn('Original');
        DisplayDebugImgWindow(InW, InH);
        SafeDrawBitmap(BitmapIn, GetDebugCanvas, 0, 0);
       
        Wait(5000);
       
        WriteLn('Resize');
        DisplayDebugImgWindow(OutW, OutH);
        SafeDrawBitmap(BitmapOut, GetDebugCanvas, 0, 0);
      finally
        FreeBitmap(BitmapIn);
        FreeBitmap(BitmapOut);
      end;
    end.

  5. #5
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Thanks, i figured that out already. And I use "fastdrawsizetransparent" now .

    Code:
    WriteLn('Original');
        DisplayDebugImgWindow(InW, InH);
        SafeDrawBitmap(BitmapIn, GetDebugCanvas, 0, 0);
        
        Wait(5000);
        
        WriteLn('Resize');
        DisplayDebugImgWindow(OutW, OutH);
        SafeDrawBitmap(BitmapOut, GetDebugCanvas, 0, 0);
    Thats pretty awesome for debugging : D.. thanks.

    ~caused

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •