如何访问由 StretchDIBits 更改的视图中的原始像素

发布于 2025-01-05 23:18:06 字数 270 浏览 4 评论 0原文

我们的旧应用程序中的视图正在使用 StretchDIBits 显示图像。如果您不熟悉 StretchDIBits,它用于在 MFC 视图上将给定尺寸的图像显示为另一个尺寸。例如,使用该函数可以将尺寸为(128,120)的图像显示在(512,512)上。

在显示器的宽度或高度是图像宽度或高度的倍数的简单情况下,我可以毫无问题地从显示器的位置计算原始图像中像素的位置。但在另一种情况下,我认为我需要知道 StretchDIBits 如何将原始图像中的像素分布到给定大小的显示矩形,特别是当两者大小之间没有倍数时。

A View in our legacy application is displaying an image using StretchDIBits. In case you are not familiar with StretchDIBits, it is used to display an image with given size to another size on MFC View. For example, an image of size (128,120) can be displayed on (512,512) with the function.

In simple condition where width or height of display is multiple of that of the image, I can calculate location of a pixel in original image from location of the display without problem. But in the other case, I think I need to know how StretchDIBits distributes pixels from original image to display rectangle of given size, especially when there is no multiples between sizes of the two.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2025-01-12 23:18:06

我不知道 StretchDIBits 如何将输入像素映射到输出像素,而且我怀疑它可能会因 Microsoft 的突发奇想而发生变化。

创建与输入大小相同的图像,并用递增值填充像素:(0,0) 获取 RGB(0,0,0),(0,1) 获取 RGB(0,1,0),(10 ,20) 获取 RGB(10,20,0) 等。创建一个与输出大小相同的内存 DC,并使用 StretchDIBits 将图像绘制到其中。现在,该 DC 中的每个像素都可以通过其包含的颜色映射回输入。

I don't know how StretchDIBits maps input pixels to output pixels, and I suspect it's subject to change at Microsoft's whim anyway.

Create an image the same size as your input, and fill the pixels with incrementing values: (0,0) gets RGB(0,0,0), (0,1) gets RGB(0,1,0), (10,20) gets RGB(10,20,0), etc. Create a memory DC the same size as your output and use StretchDIBits to draw the image into it. Now every pixel in that DC can be mapped back to the input by the color it contains.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文