コード例 #1
0
ファイル: helper.cpp プロジェクト: rayfung/ffbackup-client
uint64_t hton64(uint64_t host)
{
    uint64_t u = host;
    if(get_byte_order() == FF_LITTLE_ENDIAN)
    {
        uint8_t *ptr_host = (uint8_t *)&host;
        uint8_t *ptr_u = (uint8_t *)&u;
        int i, j;
        for(i = 0, j = 7; i < 8; ++i, --j)
            ptr_u[i] = ptr_host[j];
    }
    return u;
}
コード例 #2
0
ファイル: helper.cpp プロジェクト: rayfung/ffbackup-client
uint64_t ntoh64(uint64_t net)
{
    uint64_t u = net;
    if(get_byte_order() == FF_LITTLE_ENDIAN)
    {
        uint8_t *ptr_net = (uint8_t *)&net;
        uint8_t *ptr_u = (uint8_t *)&u;
        int i, j;
        for(i = 0, j = 7; i < 8; ++i, --j)
            ptr_u[i] = ptr_net[j];
    }
    return u;
}
コード例 #3
0
ファイル: template_draw.c プロジェクト: svn2github/staden
void create_image_from_buffer(image_t *image) {

    if (image->depth >= 24) {
    	image->img = XCreateImage(image->dis, CopyFromParent, image->depth, ZPixmap, 0, 
		    (char *)image->buf, image->width, image->height, 32, 0);
    } else if (image->depth >= 15) {
    	image->img = XCreateImage(image->dis, CopyFromParent, image->depth, ZPixmap, 0, 
		    (char *)image->buf, image->width, image->height, 16, 0);
    }

    //XInitImage(image->img);

    // set the byte order for use with XPutImage
    if ((LSBFirst == get_byte_order())) {
    	image->img->byte_order = LSBFirst;
    } else {
	image->img->byte_order = MSBFirst;
    }

    // bitmap_bit_order doesn't matter with ZPixmap
    image->img->bitmap_bit_order = MSBFirst;

    /*
     * Most X servers use 32-bit arrays for 24-bit depth, which is easy
     * and fast to fill out.
     *
     * We assume this too, so force 32-bit data if depth is 24.
     */
    if (image->img->depth >= 24)
        image->img->bits_per_pixel = 32;

    image->img->bytes_per_line =
	image->img->width * image->img->bits_per_pixel / 8;

    return;

}