【问题标题】:Get pixel value from BITMAP file从 BITMAP 文件中获取像素值
【发布时间】:2014-10-21 01:02:34
【问题描述】:

我使用的是 VS2010 MFC。

我想做以下步骤。

  1. 加载位图文件(640x480, 8bit)。
  2. 设置坐标。 (x,y)
  3. 从坐标(0~255)获取像素值。

但我不知道步骤...

请告诉我:)

【问题讨论】:

  • 想要在可见位图上执行此操作还是应该静默完成?

标签: bitmap mfc pixel coordinate


【解决方案1】:

这应该可行:

#include "atlimage.h" // This is neccesary to use CImage objects from GDI+

void dummy ()
{
    std::string bitmapFile = "file.bmp"; // Full path of your bitmap file
    int x = 0; // Your x coordinate
    int y = 0; // Your y coordinate

    CImage image;
    if ( SUCCEEDED ( image.Load ( bitmapFile.c_str() ) ) )
    {
        COLORREF color = image.GetPixel ( x, y );
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-27
    • 2013-04-10
    • 1970-01-01
    • 1970-01-01
    • 2013-09-06
    相关资源
    最近更新 更多