小编Mar*_*ano的帖子

从C中的位图读取BGR颜色

我试图从24位BMP文件中获取RGB值.我正在使用的图像是一个很小的图像,都是红色的,所以所有像素都应该是BGR配置B:0 G:0 R:255.我这样做:

int main(int argc, char **argv)
{
    principal();
    return 0;
}

typedef struct {
    unsigned char blue;
    unsigned char green;
    unsigned char red;
} rgb;

typedef struct {
    int ancho, alto;
    rgb *pixeles[MAX_COORD][MAX_COORD];
} tBitmapData;

void principal()
{

    FILE *fichero;
    tBitmapData *bmpdata = (tBitmapData *) malloc(sizeof(tBitmapData));
    rgb *pixel;
    int i, j, num_bytes;
    unsigned char *buffer_imag;
    char nombre[] = "imagen.bmp";
    fichero = fopen(nombre, "r");
    if (fichero == NULL)
            puts("No encontrado\n");
    else {
            fseek(fichero, 18, SEEK_SET);
            fread(&(bmpdata->ancho), sizeof((bmpdata->ancho)), …
Run Code Online (Sandbox Code Playgroud)

c pixel bitmap bgr

3
推荐指数
1
解决办法
3286
查看次数

标签 统计

bgr ×1

bitmap ×1

c ×1

pixel ×1