Results 1 to 8 of 8

Thread: Making a bitmap smaller

  1. #1
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Making a bitmap smaller

    I need to take a screenshot of the entire screen and turn it into a bitmap that is maybe 300 x 300 pixels.

    I can do CopyClientToBitmap to get the screen as a bitmap, or I could do GetClientCanvas to make a canvas that has the whole screen on it.
    That part is pretty easy.

    To make it smaller I can simply copy the bitmap's canvas onto another canvas.
    SCAR Code:
    CopyCanvas(BmpCanvas, NewCanvas, 0, 0, 800, 700, 0, 0, 300, 300);
    That will work for shrinking it to the right size, but now what?
    I need to either be able to save a canvas as a bitmap or copy the canvas onto the bitmap's canvas and then save the bitmap.

  2. #2
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Uhm, in Delphi I know BitBlt has a function to shrink, no idea if thats even helpful though.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  3. #3
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    If I'm understanding what you want, use SafeCopyCanvas combined with GetClientCanvas and GetBitmapCanvas. So it would look something like this:
    SCAR Code:
    SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(YourBitmap), 0, 0, 765, 503, 0, 0, 300, 300);
    try
      SaveBitmap(YourBitmap, YourPath);
    except
      Writeln('Couldn''t save bitmap.');
    finally
      FreeBitmap(YourBitmap);
    end;

  4. #4
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Uhm, in Delphi I know BitBlt has a function to shrink, no idea if thats even helpful though.
    Yes that could actually be very helpful, because most of this project I'm working on is done in a plugin.
    I'll have to figure out how to do the bitmap shrinking in delphi though.

    SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(YourBitmap), 0, 0, 765, 503, 0, 0, 300, 300);
    try
    Can you just copy over a bitmap's canvas and then the bitmap becomes the new canvas?
    I'll try that.

  5. #5
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    The code I posted should work, because it's pulled almost directly from the SRL function TakeScreenshot. The only difference is that I changed what was written for both canvas sizes.

  6. #6
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Wow if you copy over a bitmap's canvas it actually does become the new canvas.
    So thanks a lot that worked perfect.
    I just never thought the canvas worked like that.

    I'm working on a script to remote control a computer from another computer using nothing but SCAR.
    I just tested it with the shrinking and I can send the entire screen from one computer to another in under one second.
    So I think this will work.

  7. #7
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Glad to know I could help.

  8. #8
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by almost View Post
    I'm working on a script to remote control a computer from another computer using nothing but SCAR.
    I just tested it with the shrinking and I can send the entire screen from one computer to another in under one second.
    So I think this will work.
    Can't wait to see how that turns out

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
  •