Exemplo n.º 1
0
BOOL OSD_GetObjInfo(UINT16 wLibClass,UINT16 uIndex/*UINT8* pbIndex*/,FONTICONPROP* pFontInfo)
{
	UINT16	wIndex;
	const font_t*	font;
	
	RSC_PRINTF("Call %s:\n",__FUNCTION__);

	if(pFontInfo==NULL)
		return 0;
	
	// the content dwIndex points to is UNICODE. 
	wIndex= uIndex;
	
	font = get_font(wLibClass,&wIndex);
	if(font==NULL)	return FALSE;

	pFontInfo->m_wWidth 	= (font->width[wIndex]+7)/8;
	pFontInfo->m_wHeight	= font->height;
	pFontInfo->m_wActualWidth = font->width[wIndex];
	pFontInfo->m_bColor	= 1;

	RSC_PRINTF("Get INFOR: 0x%04x,wIndex=%d\n",wLibClass,wIndex);

	return TRUE;
}
Exemplo n.º 2
0
UINT8* 	OSD_GetRscObjData(UINT16 wLibClass,UINT16 uIndex/*UINT8* pbIndex*/,FONTICONPROP* pFontInfo)
{
	UINT16 wIndex,stride;
	const font_t*	font;
	UINT8* pbDatabuf;
	unsigned long i,j,font_width,font_height;
	const unsigned long	*pu32;
	unsigned long size,data_offset,u32 = 0,u32_offset,cur_pix,dest_offset,dest_byte_offset,dest_bit_offset;
	unsigned char *font_byte = NULL;

	RSC_PRINTF("Get LIB_ICON:  0x%04x,wIndex=%d\n",wLibClass,wIndex);

	wIndex=uIndex;
	font = get_font(wLibClass,&wIndex);
	if(font==NULL)	return NULL;

	pFontInfo->m_wWidth 	= (font->width[wIndex]+7)/8*8;
	font_height = pFontInfo->m_wHeight	= font->height;
	pFontInfo->m_wActualWidth = font->width[wIndex];
	pFontInfo->m_bColor	= 1;
	MEMSET(font_bitmap,0,font_height * pFontInfo->m_wWidth/8);
	data_offset = 0;
	for(i=0;i<wIndex;i++)
	{
		font_width = font->width[i];
		size = (font_width * font_height + 31)>>5;//32;
		data_offset += size;
	}

	pu32 = font->data + data_offset;
	font_width = font->width[wIndex];
	stride = (font_width+7)/8;
	cur_pix = 0;
	dest_offset = 0;
	u32 = 0;
	for(i=0;i<font_height;i++,dest_offset+=stride)
	{
		dest_byte_offset = 0;
		for(j=0;j<font_width;j++,cur_pix++)
		{
			u32_offset =  cur_pix & 0x1F;
			if(u32_offset == 0)
				u32	 = *(pu32 + (cur_pix>>5));
			dest_bit_offset = j & 0x07;
			if(dest_bit_offset ==0)
				font_byte = &font_bitmap[dest_offset + dest_byte_offset++];
			if(u32 & (0x80000000>>u32_offset) )
				*font_byte |= (0x80>> dest_bit_offset);
		}
	}

	pbDatabuf = font_bitmap;
	RSC_PRINTF("Get LIB_ICON:  0x%04x,wIndex=%d OK!\n",wLibClass,wIndex);

	return pbDatabuf;
}
/*!
  Get a decompressed resource data by it's head.

  \param[in] rsc_head	: resource head
  \return : if failed, return NULL, otherwise return the buffer address of the data
  */
static u8 *rsc_decompress_data(handle_t rsc_handle, rsc_comm_type_t type)
{
  u32 *p_buf_addr = NULL;
  u32 data_addr = 0, org_size = 0, cmp_size = 0, buf_size = 0, out_size = 0;
  rsc_bmp_info_t *p_bmp_info = NULL;
  rsc_head_t *p_hdr_rsc = NULL;
  rsc_comm_info_t *p_comm_info = NULL;
  u8 *p_fake = NULL;

  p_comm_info = _get_rsc_comm_info(rsc_handle, type);
  if(p_comm_info == NULL)
  {
    OS_PRINTF("rsc_decompress_data: can NOT get comm_info(type = %d), ERROR\n",
              type);
    return NULL;
  }
  p_hdr_rsc = _get_rsc_comm_head(p_comm_info);

  p_buf_addr = &p_comm_info->unzip_buf_addr;
  buf_size = p_comm_info->unzip_buf_size;

  switch(type)
  {
    case RSC_COMM_FONT:      
      data_addr = p_comm_info->rsc_hdr_addr + sizeof(rsc_font_t);
      break;
    case RSC_COMM_PAL:
      data_addr = p_comm_info->rsc_hdr_addr + sizeof(rsc_palette_t);
      break;
    case RSC_COMM_BMP:
      data_addr = p_comm_info->rsc_hdr_addr + sizeof(rsc_bitmap_t);
      break;
    case RSC_COMM_STRTAB:
      data_addr = p_comm_info->rsc_hdr_addr + sizeof(rsc_string_t);
      break;
    case RSC_COMM_SCRIPT:
      data_addr = p_comm_info->rsc_hdr_addr + sizeof(rsc_script_t);
      break;
    default:
      MT_ASSERT(0);
      return NULL;
  }

  org_size = p_hdr_rsc->org_size;
  cmp_size = p_hdr_rsc->cmp_size;
  
  switch(p_hdr_rsc->c_mode)
  {
    case  CMP_MODE_NONE:
      if(buf_size > 0)
      {
        /* buffer is ok, copy to buf */
        if(org_size > buf_size)
        {
          RSC_PRINTF(
            "RSC: buf_size is non-zero(%d), but NOT enough(%d), ERROR!\n",
            org_size, buf_size);
          MT_ASSERT(0);
        }
        else
        {
          rsc_read_data(rsc_handle, data_addr, (void *)(*p_buf_addr), org_size);
        }
      }
      else
      {
        /* no buffer, return address on FLASH */
        *p_buf_addr = data_addr;
      }
      break;

    case CMP_MODE_RLE:
      //os_mutex_lock(lock);
      if(org_size > buf_size)
      {
        RSC_PRINTF(
          "RSC: buf_size is non-zero(%d), but NOT enough(%d), ERROR!\n",
          org_size, buf_size);
        MT_ASSERT(0);
      }
      else
      {
        rsc_rle_decode(rsc_handle, (u8 *)data_addr, cmp_size, (u8 *)(*p_buf_addr));
      }
      break;

#if 0
    case CMP_MODE_ZIP:
      rsc_unzip(data, output);
      break;
#endif
    case CMP_MODE_LZ77:
      rsc_lz77_decode(rsc_handle, (u8 *)data_addr, cmp_size, (u8 *)(*p_buf_addr));
      break;

    case CMP_MODE_LZMA:
      out_size = buf_size;
      
      p_fake = mtos_malloc(cmp_size);
      MT_ASSERT(p_fake != NULL);     
      
      init_fake_mem_lzma(p_fake, cmp_size);
      
      lzma_decompress((unsigned long *)(*p_buf_addr), &out_size, (void *)data_addr, cmp_size);

      mtos_free(p_fake);
      break;

    case CMP_MODE_LZ4:
      LZ4_decompress_fast((const char *)data_addr, (char *)(*p_buf_addr), org_size);
      break;      

    case CMP_MODE_JPG: /*only for bitmap*/
      if(RSC_TYPE_BITMAP != p_hdr_rsc->type)
      {
        return NULL;
      }

      p_bmp_info = (rsc_bmp_info_t *)_get_rsc_comm_info(rsc_handle, RSC_COMM_BMP);
      MT_ASSERT(p_bmp_info != NULL);
      
      p_bmp_info->hdr_bmp.pitch = 
        rsc_jpg_decode(rsc_handle, (u8 *)data_addr, cmp_size, (u8 *)(*p_buf_addr));
      break;

    default:
      return NULL;
  }

  return (u8 *)(*p_buf_addr);
}