コード例 #1
0
ファイル: drv_st2205.c プロジェクト: KP1533TM2/lcd4linux
static void drv_st2205_blit(const int row, const int col, const int height, const int width)
{
    int r, c;
    RGBA p;
    for (r = row; r < row + height; r++) {
	for (c = col; c < col + width; c++) {
	    p = drv_generic_graphic_rgb(r, c);
	    fb[(r * h->width + c) * 3 + 0] = p.R;
	    fb[(r * h->width + c) * 3 + 1] = p.G;
	    fb[(r * h->width + c) * 3 + 2] = p.B;
	}
    }
    st2205_send_data(h, fb);
}
コード例 #2
0
ファイル: main.c プロジェクト: guitimoteo/libst2205
/*
This routine reads a png-file from disk and puts it into buff in a format
lib understands. (basically 24-bit rgb)
*/
int sendpic(st2205_handle *h, char* filename) {
    FILE *in;
    gdImagePtr im;
    unsigned char* pixels;
    int x,y;
    int p=0;
    unsigned int c,r,g,b;
    
    pixels=malloc(h->width*h->height*3);
    
    in=fopen(filename,"rb");
    if (in==NULL) return 0;
    //Should try other formats too
    im=gdImageCreateFromPng(in);
    fclose(in);
    if (im==NULL) {
	printf("%s: not a png-file.\n",filename);
	return 0;
    }

    for (y=0; y<h->width; y++) {
	for (x=0; x<h->height; x++) {
	    c = gdImageGetPixel(im, x, y);
	    if (gdImageTrueColor(im) ) {
		r=gdTrueColorGetRed(c);
		g=gdTrueColorGetGreen(c);
		b=gdTrueColorGetBlue(c);
	    } else {
		r=gdImageRed(im,c);
		g=gdImageGreen(im,c);
		b=gdImageBlue(im,c);
	    }
//	    pixels[p++]=0xff;
//	    pixels[p++]=0;
//	    pixels[p++]=0;
	    pixels[p++]=r;
	    pixels[p++]=g;
	    pixels[p++]=b;
	}
    }
    st2205_send_data(h,pixels);
    gdImageDestroy(im);
    return 1;
}