Ejemplo n.º 1
0
void print_bitmap_res(int i, NAMEINFO *info)
{
  BITMAP_NODE *node;
  BITMAPIMAGE *image;
  int count;

  node = (BITMAP_NODE *)info->rcsdata;
  image = &(node->data);
  print_bmp_hdr("bitmap", i, image->bmp_hdr);
  count = bit_to_rgb(image->bmp_hdr->biBitCount);
  print_rgb_quad("bitmap", i, image->rgb_quad, count);
  count = image->bmp_hdr->biSizeImage;
  print_bits("bitmap_bits", i, (BYTE *)image->bitmap_bits, count);
  COUTPUT(( "static BITMAPIMAGE bitmap_data_%d = {\n",i));
  COUTPUT(("bitmap_bmp_hdr_%d, bitmap_rgb_quad_%d, ", i, i));
  COUTPUT(( "bitmap_bits_%d",i));
  COUTPUT(("};\n\n"));
}
Ejemplo n.º 2
0
resp make_bitmap_resource(buffp b)
{
    WORD	rgb_count;
    DWORD	image_size;
    BITMAPINFOHEADER   *bmp_info_header;
    BITMAP_NODE  *bmp_image;
    resp r;
    RGBQUAD	*rgb_quad;
    char	*bmp_bits;

    r = res_new();
    r->type = (strp)RT_BITMAP;
    r->flags = FLAG_DEFAULT;

    if (*(char *)b->buffer != 'B' ||
            *(((char *)b->buffer) + 1) != 'M')
        FATAL(("Invalid bitmap resource"));

    ALLOC(bmp_info_header, BITMAPINFOHEADER);
    get_bmp_info_header(bmp_info_header, (BYTE *)b->buffer + BMP_FILE_HEADER);

    rgb_count = bit_to_rgb(bmp_info_header->biBitCount);
    CALLOC(rgb_quad, rgb_count, RGBQUAD);
    memcpy(rgb_quad, (BYTE *)b->buffer + BMP_FILE_HEADER + bmp_info_header->biSize,
           rgb_count * sizeof(RGBQUAD));

    image_size = bmp_info_header->biSizeImage;
    NALLOC(bmp_bits, image_size, char *);
    memcpy(bmp_bits, (BYTE *)b->buffer + BMP_FILE_HEADER +
           bmp_info_header->biSize + rgb_count * sizeof(RGBQUAD),
           image_size);

    BUFF_STRUCT(r->b, bmp_image, BITMAP_NODE);

    bmp_image->data.bmp_hdr = bmp_info_header;
    bmp_image->data.rgb_quad = rgb_quad;
    bmp_image->data.bitmap_bits = (BYTE*)bmp_bits;

    buff_free(b);

    return r;
}
Ejemplo n.º 3
0
void print_icon_res(int i, NAMEINFO *info)
{
  ICON_NODE *node;
  ICONIMAGE *image;
  int count;

  node = (ICON_NODE *)info->rcsdata;
  image = &(node->data);
  print_bmp_hdr("icon", i, image->icon_bmp_hdr);
  count = bit_to_rgb(image->icon_bmp_hdr->biBitCount);
  print_rgb_quad("icon", i, image->icon_rgb_quad, count);
  count = (int)(image->icon_bmp_hdr->biHeight * image->icon_bmp_hdr->biWidth * image->icon_bmp_hdr->biBitCount)/16;
  print_bits("icon_xor_bits", i, (BYTE *)image->icon_xor_mask, count);
  count = (image->icon_bmp_hdr->biHeight * image->icon_bmp_hdr->biWidth)/16;
  print_bits("icon_and_bits", i, (BYTE *)image->icon_and_mask, count);
  COUTPUT(( "static ICONIMAGE icon_data_%d = {\n",i));
  COUTPUT(("icon_bmp_hdr_%d, icon_rgb_quad_%d, ", i, i));
  COUTPUT(( "icon_xor_bits_%d, icon_and_bits_%d",i,i));
  COUTPUT(("};\n\n"));
}
Ejemplo n.º 4
0
void print_cursor_res(int i, NAMEINFO *info)
{
  CURSOR_NODE *node;
  CURSORIMAGE *image;
  int count;

  node = (CURSOR_NODE *)info->rcsdata;
  image = &(node->data);
  print_bmp_hdr("cursor", i, image->bmp_hdr);
  count = (int)bit_to_rgb(image->bmp_hdr->biBitCount);
  print_rgb_quad("cursor", i, image->rgb_quad, count);
  count = (image->bmp_hdr->biHeight * image->bmp_hdr->biWidth)/16;
  print_bits("cursor_xor_bits", i, (BYTE *)image->xor_mask, count);
  print_bits("cursor_and_bits", i, (BYTE *)image->and_mask, count);
  COUTPUT(( "static CURSORIMAGE cursor_data_%d = {\n",i));
  COUTPUT(("\t0x%04x, 0x%04x, ",image->wHotSpotX, image->wHotSpotY)); 
  COUTPUT(("cursor_bmp_hdr_%d, cursor_rgb_quad_%d, ", i, i));
  COUTPUT(("cursor_xor_bits_%d, cursor_and_bits_%d", i, i));
  COUTPUT(("};\n\n"));
}
Ejemplo n.º 5
0
resp make_icon_resource(buffp b)
{
    BYTE *temp;
    WORD	i, type, count, rgb_count;
    ICONDIR_NODE *cur_entry, *icon_entry_table;
    ICON_NODE *cur_image;
    DWORD	image_offset, image_size;
    BYTE	*temp_offset;
    BITMAPINFOHEADER  *bmp_info_header;
    RGBQUAD	*rgb_quad;
    char	*XOR_bits, *AND_bits;
    WORD	mask_bytes;
    static unsigned IdOrdinal = 1;
    resp r, rIcon;

    type = get_word((BYTE *)b->buffer + TYPE_OFFSET);
    count = get_word((BYTE *)b->buffer + TYPE_OFFSET + 2);
    if (type != 1)
        FATAL(("Invalid icon resource, type=%d", type));

    r = res_new();
    r->type = (char *)RT_GROUP_ICON;
    r->flags = FLAG_DEFAULT;

    r->b = buff_alloc(count * sizeof(ICONDIR_NODE));
    r->b->len = r->b->alloc;
    icon_entry_table = (ICONDIR_NODE *)r->b->buffer;

    cur_entry = icon_entry_table;
    cur_entry->next = (ICONDIR_NODE *)NULL;
    i = 0;
    while (1)
    {
        temp = (BYTE *)b->buffer + ICON_DIR_OFFSET + i * DIR_ENTRY_SIZE;
        cur_entry->data.bWidth = temp[0];
        cur_entry->data.bHeight = temp[1];
        cur_entry->data.wOrdinalNumber = IdOrdinal;
        cur_entry->data.bColorCount = temp[2];
        cur_entry->data.wPlanes = get_word(&temp[4]);
        cur_entry->data.wBitsPerPel = 0; /* Unused by library */
        cur_entry->data.dwBytesInRes = 0; /* Unused by library */
        image_size = get_dword(&temp[8]);
        image_offset = get_dword(&temp[12]);

        temp_offset = (BYTE *)b->buffer + image_offset;

        ALLOC(bmp_info_header, BITMAPINFOHEADER);
        get_bmp_info_header(bmp_info_header, temp_offset);
        temp_offset += bmp_info_header->biSize;

        rgb_count = bit_to_rgb(bmp_info_header->biBitCount);
        CALLOC(rgb_quad, rgb_count, RGBQUAD);
        memcpy((char *)rgb_quad, (char *)temp_offset,sizeof(RGBQUAD)*rgb_count);
        temp_offset += sizeof(RGBQUAD) * rgb_count;

        mask_bytes =  (int)(bmp_info_header->biWidth *
                            bmp_info_header->biHeight * bmp_info_header->biBitCount) / 16;

        NALLOC(XOR_bits, mask_bytes, char *);
        memcpy(XOR_bits, (char *)temp_offset, mask_bytes);
        temp_offset += mask_bytes;

        mask_bytes /=  bmp_info_header->biBitCount;
        /* AND mask is always MonoChrome */

        NALLOC(AND_bits, mask_bytes, char *);
        memcpy(AND_bits, (char *)temp_offset, mask_bytes);

        rIcon = res_new();
        BUFF_STRUCT(rIcon->b, cur_image, ICON_NODE);
        cur_image->data.icon_bmp_hdr = bmp_info_header;
        cur_image->data.icon_rgb_quad = rgb_quad;
        cur_image->data.icon_xor_mask = (BYTE*)XOR_bits;
        cur_image->data.icon_and_mask = (BYTE*)AND_bits;

        rIcon->type = RT_ICON;
        rIcon->name = (const char *)(IdOrdinal);
        /* Flags? */
        add_common_resource(rIcon);

        IdOrdinal++;
        if (count == ++i)
            break;
        else {
            ALLOC(cur_entry->next, ICONDIR_NODE);
            cur_entry = cur_entry->next;
            cur_entry->next = (ICONDIR_NODE *)NULL;
        }
    }

    buff_free(b);

    return r;
}