在Windows中绘制位数组(RGB) [英] Draw array of bits(rgb) in windows

查看:45
本文介绍了在Windows中绘制位数组(RGB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个原始的rgb数据数组.我想知道如何在Windows OS的屏幕上绘制此像素?

I have an array of raw rgb data. I would like to know how can I draw this pixels on the screen in Windows OS?

现在我使用API​​函数DrawDIBits,但必须打开图像数据.

Now I use API function DrawDIBits, but I must turn up my image data.

推荐答案

我总是使用SetDiBitsToDevice,但是drawDIBits也可以(没有检查).

I always use SetDiBitsToDevice, but drawDIBits could be okay as well (haven't checked).

关于Windows blit函数的颠倒性质:

As for the upside-down nature of the windows blit functions:

有一种解决方法.如果将BITMAPINFOHEADER或BITMAPINFO结构传递给该函数,则只需取反bitmap-height成员中的值即可.这将告诉GDI进行blit处理,就好像高度为正数一样,但是会将数据解释为以自顶向下的顺序存储的蜜蜂.

There is a workaround. If you pass a BITMAPINFOHEADER or BITMAPINFO structure to the function just negate the value in the bitmap-height member. This will tell GDI to do the blit as if the height would be positive, but interpret the data as beeing stored in a top-down order.

您也可以通过此"hack"获得不错的速度改进.

You may get a nice speed improvement by this "hack" as well.

如果您想改组像素的字节顺序(例如,将ARGB转换为BGRA左右),则可以使用BITMAPV4HEADER结构,并告诉GDI您的像素数据的组织方式.该功能很少使用,但自WIN98起可用.我想说这些天使用起来很省钱.

If you want to shuffle the byte-order of the pixels (e.g. turn ARGB into BGRA or so) you can use the BITMAPV4HEADER structure and tell GDI how your pixel-data is organized. That's a functionality that is rarely used but works since WIN98. I'd say it's save to use it these days..

这篇关于在Windows中绘制位数组(RGB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆