本文介绍了从ARGB1555位图转换为RGB8888的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一点脑屁的权利,但我需要帮助从ARGB1555将图像转换为RGB8888。

Having a bit of a brain fart right now, but I'm needing help converting an image from ARGB1555 to RGB8888.

我已经拥有了通过每个像素(读取基本的文件u16s)的那张循环,我想将它们存储为U32来代替。我想我只想用一些二进制运算符来获得2-6,7-11,12-16位,然后用另算每种颜色哪里更改各自RGB8888价值......但我真的穿上'知道如何做到这一点。

I already have the loop that goes through each of the pixels (reads u16s from a file essentially), and I would like to store them as a u32 instead. I'd suppose I would just use some binary operator to get the 2-6, 7-11, and 12-16 bits, then use another operator to somehow change each color to their respective RGB8888 value... but I really don't know how to do this.

推荐答案

您剪掉状态是什么语言你写它,但这里是一个C ++函数吧:
它需要在ARGB1555 16位整数,并在ARGB8888返回一个32位的整数

You didnt state what language you are writing it in but here is a C++ function for it:It takes the 16 bit integer in ARGB1555 and returns a 32 bit integer in ARGB8888

unsigned int ARGB1555toARGB8888(unsigned short c)
{
    const unsigned int a = c&0x8000, r = c&0x7C00, g = c&0x03E0, b = c&0x1F;
    const unsigned int rgb = (r << 9) | (g << 6) | (b << 3);
    return (a*0x1FE00) | rgb | ((rgb >> 5) & 0x070707);
}

参考:

这篇关于从ARGB1555位图转换为RGB8888的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 18:42