C++ Getting RGB from hBitmap

前端 未结 2 1967
野趣味
野趣味 2021-02-06 07:27

Working with bitmaps is very new to me so I\'ve been really struggling with the online tutorials and strategies that I\'ve read through. Basically my goal is to scan the screen

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 07:56

    Your image size is specified in pixels, it should be specified in bytes

    **bmi.biSizeImage = ScreenX * ScreenY;**
    **bmi.biBitCount = 24;**
    bmi.biWidth = ScreenX;
    bmi.biHeight = -ScreenY;
    **bmi.biCompression = BI_RGB;**
    

    biSizeImage its defined units are bytes and you are specifying RGB 3 bytes per pixel.

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx

    biSizeImage The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps.

提交回复
热议问题