Example #1
0
/*
*******************************************************************************
*                     Parse_Pic_BMP
*
* Description:
*    以路径名来解析图片, 并且把解析处理的图片拷贝到指定的地址,
* 如果指定的地址为NULL, 则可以存放在任何地址。
*
* Parameters:
*    Path           :  input.  图片路径
*    PictureInfo    :  output. 图片解析后的信息
*    Addr			:  input.  存放解析后的图片, 
*
* Return value:
*    void
*
* note:
*    void
*
*******************************************************************************
*/
__s32 Parse_Pic_BMP_ByPath(char *Path, Picture_t *PictureInfo, __u32 Addr)
{
    HBMP_i_t hbmp_buf;
    HBMP  hbmp = NULL;
    
    eLIBs_memset(&hbmp_buf, 0, sizeof(HBMP_i_t));
    hbmp = open_bmp(Path, &hbmp_buf);
    if(hbmp == NULL){
        __wrn("ERR: open_bmp failed\n");
        return -1;
    }

    PictureInfo->BitCount = get_bitcount(hbmp);
	PictureInfo->Width    = get_width(hbmp);
	PictureInfo->Height	  = get_height(hbmp);
	PictureInfo->RowSize  = get_rowsize(hbmp);

	PictureInfo->BufferSize = PictureInfo->RowSize * PictureInfo->Height;
	if(Addr){
		PictureInfo->Buffer = (void *)Addr;
	}else{
		PictureInfo->Buffer = (void *)esMEMS_Balloc(PictureInfo->BufferSize);
	}
	if(PictureInfo->Buffer == NULL){
		__wrn("ERR: wboot_malloc failed\n");
        goto error;
	}

	eLIBs_memset(PictureInfo->Buffer, 0, PictureInfo->BufferSize);

	get_matrix(hbmp, PictureInfo->Buffer);

	close_bmp(hbmp);
	hbmp = NULL;

    return 0;

error:
	close_bmp(hbmp);
	
	return -1;
}
Example #2
0
t_bunny_pixelarray	*bmp_loader(const char *path)
{
  t_bunny_pixelarray	*img;
  t_bitmap_header	bitmap;
  int			fd;

  fd = open_bmp(path);
  bitmap = bmp_header(fd);
  my_printf("[Image][BMP] load...\n");
  if (bitmap.fileheader.filetype[0] == 'B' &&
      bitmap.fileheader.filetype[1] == 'M')
    {
      img = bunny_new_pixelarray(bitmap.width, bitmap.height);
      if (img != NULL)
	my_printf("[Image][BMP] Ok...\n");
      bmp_to_pixel(fd, img, &bitmap);
    }
  else
    my_printf("[Image][BMP] Error...\n");
  return (img);
}
Example #3
0
File: main.c Project: kirbyUK/bmp
int main(int argc, char* argv[])
{
	if(argc != 2)
	{
		fprintf(stderr, "Error: No argument given\n");
		return 1;
	}

	struct BMP* b = open_bmp(argv[1]);
	if(b != NULL)
	{
		printf("BITMAPFILEHEADER:\n");
		printf("Size: %d bytes\n", b->size);
		printf("Pixel offset: %d\n", b->offset);

		printf("\nBITMAPINFOHEADER:\n");
		printf("Size of header: %d\n", b->infoheader_size);
		printf("Dimensions: %dpx x %dpx\n", b->width, b->height);
		printf("Bits per pixel: %d\n", b->bits_per_pixel);
		printf("Compression: %d\n", b->compression);
		printf("Image size: %d\n", b->img_size);
		printf("Pixels-per-metre: %dpx x %dpx\n", b->x_pixels_per_metre,
			b->y_pixels_per_metre);
		printf("Number of colours: %d\n", b->num_colours);
		printf("Important colours: %d\n", b->important_colours);

		printf("\nData:\n");
		for(int i = 0; i < b->height; i++)
		{
			printf("%d:\t", i);
			for(int j = 0; j < b->width; j++)
				printf("#%02x%02x%02x ", b->data[i][j].r, b->data[i][j].g,
					b->data[i][j].b);
			printf("\n");
		}
		free_bmp(b);
		return 0;
	}
	return 1;
}