この質問は以前に尋ねられたことを知っています。元のスレッドは、16 ビット RGB フレーム バッファを表示可能な形式に変換する方法です。しかし、私は自分の欲望の出力を得ていません。
現在、私はフレームバッファを扱っています。正確な図は、(「adb」シェルを介して) Android 携帯のフレーム バッファー (/dev/graphics/fb0) にアクセスしていることです。フレームバッファを取得するために「dd」を使用しました。
cd /dev/graphics
dd if=fb0 of=/sdcard/fb0.raw bs=1 count=width*height*3 //this width and height are based on mobile screen specification. And 3 is for RGB888
私はこのコードを使用しました -
#include <stdio.h>
#include <stdlib.h>
#include <bmpfile.h>
int main(int argc, char **argv)
{
bmpfile_t *bmp;
int i, j;
char* infilename;
FILE* infile;
char* outfile;
int width;
int height;
int depth;
unsigned char red, green, blue; // 8-bits each
unsigned short pixel; // 16-bits per pixel
//rgb_pixel_t bpixel = {128, 64, 0, 0};
//make && ./raw565tobmp fb.rgb565 720 480 32 fb.bmp && gnome-open fb.bmp
if (argc < 6) {
printf("Usage: %s infile width height depth outfile.\n", argv[0]);
exit(EXIT_FAILURE);
}
infilename = argv[1];
outfile = argv[5];
infile = fopen(infilename, "rb");
if (NULL == infile) {
perror("Couldn't read infile");
exit(EXIT_FAILURE);
}
width = atoi(argv[2]);
height = atoi(argv[3]);
depth = atoi(argv[4]);
// should be depth/8 at 16-bit depth, but 32-bit depth works better
short buffer[height*width*(depth/16)];
printf("depth: %d", depth);
if (fread(&buffer, 1, height*width*(depth/16), infile) != height*width*(depth/16)) {
fputs("infile dimensions don't match the size you supplied\n", stderr);
}
printf("depth: %d", depth);
if ((bmp = bmp_create(width, height, depth)) == NULL) {
printf("Invalid depth value: '%d'. Try 1, 4, 8, 16, 24, or 32.\n", depth);
exit(EXIT_FAILURE);
}
for (i = 0; i < width; ++i) { // 720
for (j = 0; j < height; ++j ) { // 480
pixel = buffer[width*j+i];
red = (unsigned short)((pixel & 0xFF0000) >> 16); // 8
green = (unsigned short)((pixel & 0x00FF00) >> 8); // 8
blue = (unsigned short)(pixel & 0x0000FF); // 8
rgb_pixel_t bpixel = {blue, green, red, 0};
bmp_set_pixel(bmp, i, j, bpixel);
}
}
bmp_save(bmp, outfile);
bmp_destroy(bmp);
return 0;
}
このプログラムの入力 - ./a.out fb0.raw 480 854 24 /data/new.bmp
argv[1]=入力ファイル
argv[2]=幅
argv[3]=高さ
argv[4]=深さ
argv[5]=出力ファイル
元々、コードはここに示されています。16 ビット RGB フレーム バッファを表示可能な形式に変換する方法は?
ここで bmp ファイルを開いた後、すべてがBLACKになっています。これはなぜですか?
フレームバッファを表示する方法は?