How to create screenshots picture from specified coordinates.

So I'm looking for a function that creates bitmaps taken from screen like a screenshot.

I've found this;
HBITMAP CreateBitmap(int nWidth,int nHeight,UINT cPlanes,UINT cBitsPerPel,CONST VOID *lpvBits);

But I don't understand what an HBITMAP is or what an CONST VOID *lpvBits is.
So I don't get how to use it.

I'm looking for a function that saves a bitmap in my current 32-bit system with screen specified height and width. Should look like;

[code]BitmapTypeOrStruct bitmap = CreateBitmap(int xs,int ys,int xe,int ye, 32-bit);[/code]

Then i thought i would compare bitmaps, forexample
[code]if(bitmap1==bitmap2) break;[/code]

So if someone knows how to save screenshots and later compare them tell me plz.

//ColacX you get my point do you?

Comments

  • : So I'm looking for a function that creates bitmaps taken from screen
    : like a screenshot.
    :
    : I've found this;
    : HBITMAP CreateBitmap(int nWidth,int nHeight,UINT cPlanes,UINT
    : cBitsPerPel,CONST VOID *lpvBits);
    :
    : But I don't understand what an HBITMAP is or what an CONST VOID
    : *lpvBits is.
    : So I don't get how to use it.
    :
    : I'm looking for a function that saves a bitmap in my current 32-bit
    : system with screen specified height and width. Should look like;
    :
    : [code]: BitmapTypeOrStruct bitmap = CreateBitmap(int xs,int ys,int xe,int ye, 32-bit);[/code]:
    :
    : Then i thought i would compare bitmaps, forexample
    : [code]: if(bitmap1==bitmap2) break;[/code]:
    :
    : So if someone knows how to save screenshots and later compare them
    : tell me plz.
    :
    : //ColacX you get my point do you?
    :
    HBITMAP is a handle to a bitmap object.
    *lpvBits is the actual pixel data.
    Here's how to make a bitmap using the function you found:
    [code]
    var
    bitmap: TBitmap;
    P: Pointer;
    begin
    bitmap := TBitmap;
    P := AllocMem(nWidth*nHeight*cBitsPerPel/8);
    // Fill P here
    bitmap.Handle := CreateBitmap(nWidth, nHeight, 1, cBitsPerPel, P);
    end;
    [/code]
    The if-then statement probably won't work, because the bitmaps might only hold references (pointers/handles) to the actual data.
  • : HBITMAP is a handle to a bitmap object.
    : *lpvBits is the actual pixel data.
    : Here's how to make a bitmap using the function you found:
    : [code]:
    : var
    : bitmap: TBitmap;
    : P: Pointer;
    : begin
    : bitmap := TBitmap;
    : P := AllocMem(nWidth*nHeight*cBitsPerPel/8);
    : // Fill P here
    : bitmap.Handle := CreateBitmap(nWidth, nHeight, 1, cBitsPerPel, P);
    : end;
    : [/code]:
    : The if-then statement probably won't work, because the bitmaps might
    : only hold references (pointers/handles) to the actual data.

    Ehum I had to rewrite it into .net format i think for delphi.
    [code]void __fastcall TForm1::Button8Click(TObject *Sender)
    {
    TBitmap bitmap;
    Pointer P;
    int nWidth,nHeight,cBitsPerPel;
    P = AllocMem(nWidth*nHeight*cBitsPerPel/8);
    // Fill P here
    bitmap.Handle = CreateBitmap(nWidth, nHeight, 1, cBitsPerPel, P);
    }[/code]
    It says
    [C++ Error] Unit1.cpp(99): E2015 Ambiguity between 'TBitmap' and 'Windows::TBitmap'
    [C++ Error] Unit1.cpp(99): E2459 VCL style classes must be constructed using operator new
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories