WriteRes.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:142k
源码类别:
MTK
开发平台:
C/C++
- * Load_Audio_Data
- * DESCRIPTION
- * load and write audio header and data
- * PARAMETERS
- * offset [OUT] File offset --> file offset
- * output_file [IN] -> Name of the file to which buffer
- * input_file [IN] -> Name of the input audio file
- * pImgData [OUT] -> buffer containing image data
- * audio_identifier [IN] -> audio identifier
- * is(?) [IN] To be written
- * RETURNS
- * S32 --> file size
- *****************************************************************************/
- S32 Load_Audio_Data(U32 *offset, FILE *output_file, FILE *input_file, U8 *pImgData, U8 audio_identifier)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 file_size, i, o = 0;
- U8 ch;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- fseek(input_file, 0, SEEK_END);
- file_size = ftell(input_file);
- fseek(input_file, 0, SEEK_SET);
- if (toolFlag)
- {
- fprintf(
- dest_file,
- "%c%c%c%c%c%c%c%c",
- audio_identifier,
- file_size & 0xff,
- (file_size & 0xff00) >> 8,
- (file_size & 0xff0000) >> 16,
- (file_size & 0xff000000) >> 24,
- 0,
- 0,
- 0);
- }
- else
- {
- fprintf(
- output_file /* output_data_file */ ,
- "nt0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x00, 0x00, 0x00,nt",
- audio_identifier,
- file_size & 0xff,
- (file_size & 0xff00) >> 8,
- (file_size & 0xff0000) >> 16,
- (file_size & 0xff000000) >> 24);
- }
- pImgData[0] = (U8) audio_identifier;
- pImgData[1] = (U8) (file_size & 0xff);
- pImgData[2] = (U8) ((file_size & 0xff00) >> 8);
- pImgData[3] = (U8) ((file_size & 0xff0000) >> 16);
- pImgData[4] = (U8) ((file_size & 0xff000000) >> 24);
- for (i = 0; i < file_size; i++)
- {
- ch = fgetc(input_file);
- if (toolFlag)
- {
- fputc(ch, dest_file);
- (*offset)++;
- (pImgData)[i + 6] = ch;
- }
- else
- {
- fprintf(output_file, "0x%02X, ", ch);
- (*offset)++;
- (pImgData)[i + 6] = ch;
- o++;
- if ((o % 16) == 0)
- {
- fprintf(output_file, "nt");
- }
- }
- }
- return file_size + 8;
- }
- /* 101205 audio resource Calvin End */
- /*****************************************************************************
- * FUNCTION
- * Write_Sequential_Image_Header
- * DESCRIPTION
- * Construct the header for sequential images
- * PARAMETERS
- * output_file [IN] -> output file handle
- * image_identifier [IN] -> sequential image type
- * n_frames [IN] -> the number of the frames
- * seq_filesize [IN] -> pointer to a list of file sizes
- * seq_offset [OUT] -> pointer to a list of offsets
- * RETURNS
- * void
- *****************************************************************************/
- void Write_Sequential_Image_Header(
- FILE *output_file,
- U8 image_identifier,
- S32 n_frames,
- S32 *seq_filesize,
- S32 *seq_offset)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- S32 offset = 8;
- S32 real_size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (toolFlag == 1)
- {
- fprintf(dest_file, "%c%c%c%c%c%c%c%c", image_identifier, n_frames, 0, 0, 0, 0, 0, 0); /* the major header */
- for (i = 0; i < n_frames; i++)
- {
- int interval = sequential_interval[i];
- seq_offset[i] = offset;
- real_size = ((seq_filesize[i] + 3) >> 2) << 2;
- fprintf(dest_file, "%c%c%c%c", seq_offset[i] & 0xff, (seq_offset[i] & 0xff00) >> 8, (seq_offset[i] & 0xff0000) >> 16, (seq_offset[i] & 0xff000000) >> 24); /* the offset for each file */
- fprintf(dest_file, "%c%c%c%c", seq_filesize[i] & 0xff, (seq_filesize[i] & 0xff00) >> 8, (seq_filesize[i] & 0xff0000) >> 16, (seq_filesize[i] & 0xff000000) >> 24); /* the size for each file */
- fprintf(dest_file, "%c%c%c%c", interval & 0xff, (interval & 0xff00) >> 8, (interval & 0xff0000) >> 16, (interval & 0xff000000) >> 24); /* the interval for each file */
- offset += real_size;
- }
- }
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- else if (enfbFlag == 1) /* write ENFB header to CustImgDataxxx.h and image header/data to ENFB image data file */
- {
- S32 data_size = 0;
- for (i = 0; i < n_frames; i++)
- {
- real_size = ((seq_filesize[i] + 3) >> 2) << 2;
- data_size += real_size;
- }
- enfb_size = 8 + 12*n_frames + data_size;
- /* write ENFB header to CustImgDataxxx.h */
- fprintf(
- output_file,
- "nt0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02Xt",
- (U8) 255,//type
- (U8) ENFBAssociatedIDAdded,//associated id
- (U8) 0,//reserved
- (U8) 0,//reserved
- (U8) (enfb_offset & 0xff),
- (U8) ((enfb_offset >> 8) & 0xff),
- (U8) ((enfb_offset >> 16) & 0xff),
- (U8) ((enfb_offset >> 24) & 0xff),
- (U8) (enfb_size & 0xff),
- (U8) ((enfb_size >> 8) & 0xff),
- (U8) ((enfb_size >> 16) & 0xff),
- (U8) ((enfb_size >> 24) & 0xff));
- /* image header/data to ENFB image data file */
- fprintf(enfb_img_data_file, "%c%c%c%c%c%c%c%c", image_identifier, n_frames, 0, 0, 0, 0, 0, 0); /* the major header */
- for (i = 0; i < n_frames; i++)
- {
- int interval = sequential_interval[i];
- seq_offset[i] = offset;
- real_size = ((seq_filesize[i] + 3) >> 2) << 2;
- fprintf(enfb_img_data_file, "%c%c%c%c", seq_offset[i] & 0xff, (seq_offset[i] & 0xff00) >> 8, (seq_offset[i] & 0xff0000) >> 16, (seq_offset[i] & 0xff000000) >> 24); /* the offset for each file */
- fprintf(enfb_img_data_file, "%c%c%c%c", seq_filesize[i] & 0xff, (seq_filesize[i] & 0xff00) >> 8, (seq_filesize[i] & 0xff0000) >> 16, (seq_filesize[i] & 0xff000000) >> 24); /* the size for each file */
- fprintf(enfb_img_data_file, "%c%c%c%c", interval & 0xff, (interval & 0xff00) >> 8, (interval & 0xff0000) >> 16, (interval & 0xff000000) >> 24); /* the interval for each file */
- offset += real_size;
- }
- enfb_offset += enfb_size;
- }
- #endif
- /* 100206 ENFB support End */
- else
- {
- fprintf(output_file, "nt0x%02X, 0x%02X, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,nt", image_identifier, n_frames); /* the major header */
- for (i = 0; i < n_frames; i++)
- {
- int interval = sequential_interval[i];
- seq_offset[i] = offset;
- real_size = ((seq_filesize[i] + 3) >> 2) << 2;
- fprintf(output_file, "0x%02X, 0x%02X, 0x%02X, 0x%02X, ", seq_offset[i] & 0xff, (seq_offset[i] & 0xff00) >> 8, (seq_offset[i] & 0xff0000) >> 16, (seq_offset[i] & 0xff000000) >> 24); /* the offset for each file */
- fprintf(output_file, "0x%02X, 0x%02X, 0x%02X, 0x%02X, ", seq_filesize[i] & 0xff, (seq_filesize[i] & 0xff00) >> 8, (seq_filesize[i] & 0xff0000) >> 16, (seq_filesize[i] & 0xff000000) >> 24); /* the size for each file */
- fprintf(output_file, "0x%02X, 0x%02X, 0x%02X, 0x%02X,nt", interval & 0xff, (interval & 0xff00) >> 8, (interval & 0xff0000) >> 16, (interval & 0xff000000) >> 24); /* the interval for each file */
- offset += real_size;
- g_ressize += seq_filesize[i];
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * Write_Sequential_Image_File
- * DESCRIPTION
- * Write raw date from a frame of an image to the output file
- * PARAMETERS
- * output_file [IN] -> output file handle
- * input_file [IN] -> input file handle
- * filesize [IN] -> the input file size
- * RETURNS
- * void
- *****************************************************************************/
- void Write_Sequential_Image_File(FILE *output_file, FILE *input_file, S32 filesize)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 i;
- U32 o = 0;
- U8 ch;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (toolFlag == 1)
- {
- for (i = 0; i < filesize; i++)
- {
- ch = fgetc(input_file);
- fprintf(dest_file, "%c", ch);
- }
- for (i = filesize; i % 4 != 0; i++)
- {
- fprintf(dest_file, "%c", 0); /* for 4 byte alignment */
- }
- }
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- else if (enfbFlag == 1) /* write ENFB header to CustImgDataxxx.h and image header/data to ENFB image data file */
- {
- for (i = 0; i < filesize; i++)
- {
- ch = fgetc(input_file);
- fprintf(enfb_img_data_file, "%c", ch);
- }
- for (i = filesize; i % 4 != 0; i++)
- {
- fprintf(enfb_img_data_file, "%c", 0); /* for 4 byte alignment */
- }
- }
- #endif
- /* 100206 ENFB support End */
- else
- {
- for (i = 0; i < filesize; i++)
- {
- ch = fgetc(input_file);
- fprintf(output_file, "0x%02X, ", ch);
- o++;
- if ((o % 16) == 0)
- {
- fprintf(output_file, "nt");
- }
- }
- for (i = filesize; i % 4 != 0; i++)
- {
- fprintf(output_file, "0x00, "); /* for 4 byte alignment */
- }
- if ((o % 16) != 0)
- {
- fprintf(output_file, "nt");
- }
- }
- }
- /* Calvin end */
- /* __CUSTPACK_MULTIBIN Calvin END */
- /* 101205 audio resource Calvin Satrt */
- /*****************************************************************************
- * FUNCTION
- * Extract_Name
- * DESCRIPTION
- * Exract image name from the supplied string
- * PARAMETERS
- * dest [OUT] -> Extrected file name from string
- * src [IN] -> string containing file name and path
- * res_type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void Extract_Name(S8 *dest, S8 *src, U32 res_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 iLen = strlen(src);
- U16 nCount = 0;
- S8 *pSrc = src;
- char a, b;
- S8 *pCustPath;
- U32 ExtFlag;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (res_type)
- {
- case RES_IMAGE:
- case RES_MEDIA:
- case RES_JAVA_GAME:
- pCustPath = CustImgPath;
- ExtFlag = ExtImageFlag;
- break;
- case RES_AUDIO:
- pCustPath = CustAdoPath;
- ExtFlag = ExtAudioFlag;
- break;
- default:
- printf("res_type in Extract_Name is invalid!!");
- pCustPath = CustImgPath;
- ExtFlag = ExtImageFlag;
- break;
- }
- iLen = strlen(pCustPath);
- for (nCount = 0; nCount < iLen; nCount++)
- {
- a = toupper(pCustPath[nCount]);
- b = toupper(src[nCount]);
- if (a != b)
- {
- break;
- }
- }
- if (iLen == nCount)
- {
- pSrc = &src[iLen];
- }
- iLen = strlen(pSrc);
- nCount = 0;
- while (iLen)
- {
- if ((pSrc[nCount] == '.') || (pSrc[nCount] == '-') || (pSrc[nCount] == ' ') || (pSrc[nCount] == '\'))
- {
- dest[nCount] = '_';
- }
- else
- {
- dest[nCount] = pSrc[nCount];
- }
- ++nCount;
- --iLen;
- }
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- if (ExtFlag == 1) /* 040805 CustPack: Calvin added */
- {
- dest[nCount] = '_'; /* add a '_' in the end to distinguish from the original */
- dest[nCount + 1] = ' ';
- }
- /* __CUSTPACK_MULTIBIN Calvin END */
- else
- {
- dest[nCount] = ' ';
- }
- return;
- }
- /* 101205 audio resource Calvin End */
- /* 101205 audio resource Calvin Satrt */
- /* 070306 Alpha layer Start */
- /*****************************************************************************
- * FUNCTION
- * ExtractExtension
- * DESCRIPTION
- * Function Extracting the extension
- * PARAMETERS
- * src [?]
- * res_type [IN] -> resource type
- * string(?) [IN] -> string containing file name
- * RETURNS
- * U8
- *****************************************************************************/
- U8 ExtractExtension(S8 *src, U32 res_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, j;
- S32 type_number;
- U8 ret = 0;
- S8 *arr;
- RESOURCE_INFO *pResource_info;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- i = strlen(src) - 1;
- arr = src+i;
- for (j = 0; j < 5 ; j--)
- {
- if(*arr == '.')
- {
- arr++;
- break;
- }
- else
- {
- arr--;
- }
- }
- if(j >= 5)
- {
- return ret;
- }
- switch (res_type)
- {
- case RES_IMAGE:
- case RES_MEDIA:
- ret = IMAGE_TYPE_INVALID;
- pResource_info = image_resource_info;
- type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
- break;
- case RES_AUDIO:
- ret = AUDIO_TYPE_INVALID;
- pResource_info = audio_resource_info;
- type_number = sizeof(audio_resource_info) / sizeof(RESOURCE_INFO);
- break;
- default:
- printf("res_type in Extract_Name is invalid!!");
- ret = IMAGE_TYPE_INVALID;
- pResource_info = image_resource_info;
- type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
- break;
- }
- for (i = 0; i < type_number; i++)
- {
- if (!(strcmp(arr, pResource_info[i].filename_ext)))
- {
- ret = pResource_info[i].file_type;
- }
- }
- return ret;
- }
- /*****************************************************************************
- * FUNCTION
- * ChangeExtension
- * DESCRIPTION
- * Function Change the extension
- * PARAMETERS
- * src [IN] -> string containing file name
- * res_type [IN] -> resource type
- * ext_type [IN] -> extension type
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL ChangeExtension(S8 *src, U32 res_type, S32 ext_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, j;
- S32 type_number;
- U8 ret = 0;
- S8 *arr;
- RESOURCE_INFO *pResource_info;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- i = strlen(src) - 1;
- arr = src+i;
- for (j = 0; j < 5 ; j--)
- {
- if(*arr == '.')
- {
- arr++;
- break;
- }
- else
- {
- arr--;
- }
- }
- if (j >= 5)
- {
- return FALSE;
- }
- switch (res_type)
- {
- case RES_IMAGE:
- case RES_MEDIA:
- ret = IMAGE_TYPE_INVALID;
- pResource_info = image_resource_info;
- type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
- break;
- case RES_AUDIO:
- ret = AUDIO_TYPE_INVALID;
- pResource_info = audio_resource_info;
- type_number = sizeof(audio_resource_info) / sizeof(RESOURCE_INFO);
- break;
- default:
- printf("res_type in Extract_Name is invalid!!");
- ret = IMAGE_TYPE_INVALID;
- pResource_info = image_resource_info;
- type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
- break;
- }
- for (i = 0; i < type_number; i++)
- {
- if (pResource_info[i].file_type == ext_type)
- {
- break;
- }
- }
- if (i >= type_number)
- {
- return FALSE;
- }
- for (j = 0; j < 5; j++)
- {
- *(arr+j) = *(pResource_info[i].filename_ext+j);
- }
- return TRUE;
- }
- /* 070306 Alpha layer End */
- /*****************************************************************************
- * FUNCTION
- * isEmsImage
- * DESCRIPTION
- * Decide if the iamge is used for EMS picture
- *
- * use EMS_IMAGE_PATH (defined in CustDataRes.h) to decide if a EMS picture
- * PARAMETERS
- * path [IN] -> string containing file name and path
- * RETURNS
- * U8 --> 1: EMS picture, 0: Not EMS picture
- *****************************************************************************/
- U8 isEmsImage(S8 *path)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 ems_path[] = EMS_IMAGE_PATH;
- U8 pos = 0, ems_len = 0, i = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ems_len = strlen(ems_path);
- pos = strlen(path) - 1;
- while (path[pos] != '\')
- {
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- if (pos == 0) /* 040805 CustPack: Calvin added */
- {
- return 0;
- }
- /* __CUSTPACK_MULTIBIN Calvin END */
- pos--;
- }
- pos -= ems_len + 1;
- for (i = 0; i < ems_len; i++)
- {
- if (ems_path[i] != path[pos])
- {
- return 0;
- }
- else
- {
- pos++;
- }
- }
- return 1;
- }
- /*****************************************************************************
- * FUNCTION
- * isMainmenuImage
- * DESCRIPTION
- * Decide if the iamge is used for Mainmenu picture
- * PARAMETERS
- * path [IN] -> string containing file name and path
- * RETURNS
- * U8 --> 1: Matrix Mainmenu picture, 0: Not Matrix mainmenu picture
- *****************************************************************************/
- MMI_BOOL isMainmenuImage(S8 *path)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((strstr(path, "\MATRIX\") != NULL) && (strstr(path, ".GIF") != NULL))
- {
- return MMI_TRUE;
- }
- else
- {
- return MMI_FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * isSubmenuImage
- * DESCRIPTION
- * Decide if the iamge is used for Submenu picture
- *
- * use SUBMENU_IMAGE_PATH (defined in CustDataRes.h) to decide if a EMS picture
- * PARAMETERS
- * path [IN] -> string containing file name and path
- * RETURNS
- * U8 --> 1: Submenu picture, 0: Not Submenu picture
- *****************************************************************************/
- U8 isSubmenuImage(S8 *path)
- {
- #ifndef __MMI_SLIM_LISTMENU_NUMBER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return 0;
- #else /* __MMI_SLIM_LISTMENU_NUMBER__ */
- S8 submenu_path[] = SUBMENU_IMAGE_PATH;
- U8 pos = 0, submenu_len = 0, i = 0;
- if (strstr(path, submenu_path) != NULL)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- /*
- * submenu_len = strlen(submenu_path);
- * pos = strlen (path)-1;
- * while (path[pos]!='\') pos--;
- * pos-=submenu_len+1;
- * for ( i=0; i<submenu_len; i++){
- * if ( submenu_path[i] != path[pos] ) return 0;
- * else pos++;
- * }
- * return 1;
- */
- #endif /* __MMI_SLIM_LISTMENU_NUMBER__ */
- }
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- /* 040805 CustPack: Calvin added */
- /*****************************************************************************
- * FUNCTION
- * ToUpper
- * DESCRIPTION
- *
- * PARAMETERS
- * ch [IN]
- * RETURNS
- *
- *****************************************************************************/
- S8 ToUpper(S8 ch)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return toupper(ch);
- }
- /* Calvin end */
- /* __CUSTPACK_MULTIBIN Calvin END */
- /*****************************************************************************
- * FUNCTION
- * Iload
- * DESCRIPTION
- * Load the file image to buffer and writes to CustImgRes.c
- * PARAMETERS
- * string [IN] -> string containing file name and path
- * pType [OUT] -> Image Type
- * RETURNS
- * void* --> buffer containing image data
- *****************************************************************************/
- MMI_BOOL Iload(S8 *string, PU16 pType)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 image_counter = 0;
- U32 image_offset = 0;
- U32 failure_counter = 0;
- U8 *pBuffer = NULL;
- S32 j, sequence_counter, n_frames;
- MMI_BOOL failure_flag;
- U8 image_identifier;
- S32 n_images = 0;
- S32 file_size1 = 0;
- S32 file_size = 0;
- S32 nImageSize = 0;
- U8 *pBuffer1 = NULL;
- S32 extension_type = -1;
- U8 staticFlag = 1; /* Non animated image */
- /* 070306 Alpha layer Start */
- //#ifdef __MMI_ALPHA_LAYER_SUPPORT__
- S32 ext_type = -1;
- //#endif
- /* 070306 Alpha layer End */
- // __CUSTPACK_MULTIBIN Calvin BEGIN
- //S8 tempDestFile[] = {"..\\..\\Customer\\IMAGES\TEMPIMAGE"};
- S8 tempDestFile[] = { "TEMPIMAGE" }; /* 040805 CustPack: Calvin modified */
- int ret = 1;
- /* __CUSTPACK_MULTIBIN Calvin END */
- S8 tempCommand[200];
- size_t size;
- U32 o = 0;
- S16 filenameLen;
- char *curr_output_data_filename;
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- U32 enfb_width, enfb_height;//100206 ENFB support
- S32 enfb_ret;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_ressize = 0;
- if (ExtImageFlag == EXT_IMAGE)
- {
- curr_output_data_filename = OUTPUT_DATA_FILENAME_EXT;
- }
- else if (ExtImageFlag == SYSTEM_IMAGE)
- {
- curr_output_data_filename = OUTPUT_DATA_FILENAME;
- }
- else
- {
- curr_output_data_filename = NFB_IMAGE_DATA_FILENAME;
- nfb_img_res_file = fopen(NFB_IMAGE_RES_FILENAME, "ab");
- }
- if (toolFlag == 1)
- { /* 040805 CustPack: Calvin added */
- curr_output_data_filename = "temp";
- }
- strcpy(filename_buffer, curr_output_data_filename); /* 040805 CustPack: Calvin modified */
- /* __CUSTPACK_MULTIBIN Calvin END */
- output_data_file = fopen(filename_buffer, "ab");
- while (!output_data_file)
- {
- Sleep(50);
- output_data_file = fopen(filename_buffer, "ab");
- }
- //Move behind
- //fprintf(output_data_file,"const U8 ");
- output_image_names = (S8*) malloc(100);
- strcpy(filename_buffer, string);
- if (!(strcmp(filename_buffer, "")))
- {
- strcpy(filename_buffer, NOIMAGE_FILENAMEBUFFER);
- }
- Extract_Name(output_image_names, filename_buffer, RES_IMAGE);
- #ifdef __MMI_SLIM_LISTMENU_NUMBER__
- if (isSubmenuImage(filename_buffer))
- {
- int i, len;
- len = strlen(filename_buffer);
- for (i = len; i > 0; i--)
- {
- if (filename_buffer[i] == 'U' && filename_buffer[i - 1] == 'N' && filename_buffer[i - 2] == 'E' &&
- filename_buffer[i - 3] == 'M' && filename_buffer[i - 4] == 'B' && filename_buffer[i - 5] == 'U' &&
- filename_buffer[i - 6] == 'S')
- {
- filename_buffer[i + 1] = '2';
- break;
- }
- else
- {
- filename_buffer[i + 1] = filename_buffer[i];
- }
- }
- filename_buffer[len + 1] = ' ';
- }
- #endif /* __MMI_SLIM_LISTMENU_NUMBER__ */
- failure_flag = MMI_TRUE;
- extension_type = -1;
- sequence_counter = 0;
- /* 070306 Alpha layer Start */
- #ifdef __MMI_ALPHA_LAYER_SUPPORT__
- //printf("inside 1n");
- ext_type = ExtractExtension(filename_buffer, RES_IMAGE);
- if (ext_type == IMAGE_TYPE_GIF || ext_type == IMAGE_TYPE_BMP)
- {
- //printf("inside GIF..BMP %sn", filename_buffer);
- ChangeExtension(filename_buffer, RES_IMAGE, IMAGE_TYPE_PNG);
- //printf("out GIF..BMP %sn", filename_buffer);
- }
- else if (ext_type == IMAGE_TYPE_DEVICE_BITMAP)
- {
- ChangeExtension(filename_buffer, RES_IMAGE, IMAGE_TYPE_PPN);
- }
- image_data_file = fopen(filename_buffer, "rb");
- if (image_data_file == NULL)
- {
- ChangeExtension(filename_buffer, RES_IMAGE, ext_type);
- }
- else
- {
- fclose(image_data_file);
- }
- #endif
- ext_type = ExtractExtension(filename_buffer, RES_IMAGE);
- if (ext_type == IMAGE_TYPE_PPN)
- {
- //ChangeExtension(filename_buffer, RES_IMAGE, IMAGE_TYPE_PNG);
- strcpy((char*)tempBMPFile, (const char*)filename_buffer);
- ChangeExtension(tempBMPFile, RES_IMAGE, IMAGE_TYPE_DEVICE_BITMAP);
- sprintf(tempCommand,"convert.exe png:%s bmp:%s", filename_buffer, tempBMPFile);
- //sprintf(tempCommand,"convert.exe png:%s bmp:%s", filename_buffer, "4.pbm");
- //printf("%sn",tempCommand);
- system(tempCommand);
- strcpy((char*)filename_buffer, (const char*)tempBMPFile);
- //printf("%sn",filename_buffer);
- }
- /* 070306 Alpha layer End */
- filenameLen = strlen(filename_buffer);
- /* MTK Leo add, for EMS */
- if (isEmsImage(filename_buffer))
- /* if (filename_buffer[filenameLen-3] =='P' && filename_buffer[filenameLen-2] == 'I' && filename_buffer[filenameLen-1] =='C' ) */
- {
- image_data_file = fopen(filename_buffer, "rb");
- if (image_data_file != NULL)
- {
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- if (toolFlag == 0) /* 040805 CustPack: Calvin modified */
- {
- fprintf(output_data_file, "const U8 ");
- fprintf(output_data_file, output_image_names);
- fprintf(output_data_file, "[]=");
- fclose(output_data_file);
- }
- //sprintf(tempCommand,"%s %s -b %s", EMSCONVERTER_FILENAME,filename_buffer,OUTPUT_DATA_FILENAME);//,output_image_names);
- //system(tempCommand);
- ret = bmp2ems(filename_buffer, curr_output_data_filename, 1, 0); /* 040805 CustPack: Calvin modified */
- if (toolFlag)
- {
- if (ret == 0)//100206 ENFB support
- {
- resultFailFlag = 1;
- }
- }
- /* __CUSTPACK_MULTIBIN Calvin END */
- }
- else
- {
- /* fclose(image_data_file); */
- failure_flag = MMI_FALSE;
- }
- }
- else if ((filename_buffer[filenameLen - 1] == 'P' || filename_buffer[filenameLen - 1] == 'M') &&
- (filename_buffer[filenameLen - 2] == 'R' || filename_buffer[filenameLen - 2] == 'B') &&
- filename_buffer[filenameLen - 3] == 'P')
- {
- image_data_file = fopen(filename_buffer, "rb");
- if (image_data_file != NULL)
- {
- if (filename_buffer[filenameLen - 2] == 'R')
- {
- //sprintf(tempCommand,"%s %s %s", GIFCONVERTER_FILENAME,filename_buffer,tempDestFile);
- //system(tempCommand);//010505 Calvin moved
- GIFLoader(filename_buffer, tempDestFile); /* 010505 Calvin added */
- }
- else
- {
- //sprintf(tempCommand,"%s %s %s", BMPCONVERTER_FILENAME,filename_buffer,tempDestFile);
- //system(tempCommand);//010505 Calvin moved
- // __CUSTPACK_MULTIBIN Calvin BEGIN
- ret = BMPLoader(filename_buffer, tempDestFile); /* 010505 Calvin added */
- if (toolFlag)
- {
- if (ret = 0)
- {
- resultFailFlag = 1;
- }
- }
- /* __CUSTPACK_MULTIBIN Calvin END */
- }
- /* system(tempCommand);//010505 Calvin moved */
- fclose(image_data_file);
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- if (toolFlag == 0) /* 040805 CustPack: Calvin modified */
- {
- image_data_file = fopen(tempDestFile, "rb");
- if (image_data_file != NULL)
- {
- strcpy((char*)autoimagename_buffer, (const char*)output_image_names);
- strcat((char*)autoimagename_buffer, "[]=n");
- fprintf(output_data_file, "const U8 ");
- fprintf(output_data_file, autoimagename_buffer);
- if (ExtImageFlag == NFB_PROGRESS_IMAGE)
- {
- if (nfb_img_res_file != NULL)
- {
- fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
- fclose(nfb_img_res_file);
- }
- else
- {
- printf("nfb_img_res_file not openedn");
- }
- }
- fseek(image_data_file, 0, SEEK_END);
- file_size = ftell(image_data_file);
- fseek(image_data_file, 0, SEEK_SET);
- while (!feof(image_data_file))
- {
- size = fread(tempCommand, sizeof(char), 200, image_data_file);
- if (size)
- {
- fwrite(tempCommand, sizeof(char), size, output_data_file);
- }
- }
- fputs("n", output_data_file);
- }
- }
- /* __CUSTPACK_MULTIBIN Calvin END */
- }
- else
- {
- failure_flag = MMI_FALSE;
- }
- }
- else
- {
- image_data_file = fopen(filename_buffer, "rb");
- /* MTK Leo add, for read images with same filename but different in ".bmp" and ".gif" */
- if (image_data_file == NULL)
- {
- Sleep(50);
- if (filename_buffer[filenameLen - 1] == 'P' && filename_buffer[filenameLen - 2] == 'M' &&
- filename_buffer[filenameLen - 3] == 'B')
- {
- filename_buffer[filenameLen - 1] = 'F';
- filename_buffer[filenameLen - 2] = 'I';
- filename_buffer[filenameLen - 3] = 'G';
- }
- else if (isMainmenuImage(filename_buffer))
- {
- filename_buffer[filenameLen - 1] = 'M';
- filename_buffer[filenameLen - 2] = 'B';
- filename_buffer[filenameLen - 3] = 'P';
- image_data_file = fopen(filename_buffer, "rb");
- if (image_data_file != NULL)
- {
- //sprintf(tempCommand,"%s %s %s", BMPCONVERTER_FILENAME,filename_buffer,tempDestFile);
- //system(tempCommand);
- // __CUSTPACK_MULTIBIN Calvin BEGIN
- ret = BMPLoader(filename_buffer, tempDestFile); /* 010505 Calvin added */
- if (toolFlag)
- {
- if (ret = 0)
- {
- resultFailFlag = 1;
- }
- }
- /* __CUSTPACK_MULTIBIN Calvin END */
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- if (toolFlag == 0) /* 040805 CustPack: Calvin modified */
- {
- image_data_file = fopen(tempDestFile, "rb");
- if (image_data_file != NULL)
- {
- strcpy((char*)autoimagename_buffer, (const char*)output_image_names);
- strcat((char*)autoimagename_buffer, "[]=n");
- fprintf(output_data_file, "const U8 ");
- fprintf(output_data_file, autoimagename_buffer);
- if (ExtImageFlag == NFB_PROGRESS_IMAGE)
- {
- if (nfb_img_res_file != NULL)
- {
- fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
- fclose(nfb_img_res_file);
- }
- else
- {
- printf("nfb_img_res_file not openedn");
- }
- }
- fseek(image_data_file, 0, SEEK_END);
- file_size = ftell(image_data_file);
- fseek(image_data_file, 0, SEEK_SET);
- while (!feof(image_data_file))
- {
- size = fread(tempCommand, sizeof(char), 200, image_data_file);
- if (size)
- {
- fwrite(tempCommand, sizeof(char), size, output_data_file);
- }
- }
- fputs("n", output_data_file);
- }
- fclose(image_data_file);
- }
- fclose(output_data_file);
- return MMI_TRUE;
- /* __CUSTPACK_MULTIBIN Calvin END */
- }
- }
- else if (filename_buffer[filenameLen - 1] == 'F' && filename_buffer[filenameLen - 2] == 'I' &&
- filename_buffer[filenameLen - 3] == 'G')
- {
- filename_buffer[filenameLen - 1] = 'P';
- filename_buffer[filenameLen - 2] = 'M';
- filename_buffer[filenameLen - 3] = 'B';
- }
- image_data_file = fopen(filename_buffer, "rb");
- }
- /* MTK Leo end */
- if (image_data_file == NULL)
- {
- /* Add extension add search */
- FILE *fail = fopen("fail.txt", "a+");
- if (fail != NULL)
- {
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- if (toolFlag == 0) /* 040805 CustPack: Calvin modified */
- {
- fprintf(fail, "%sn", filename_buffer);
- fclose(fail);
- }
- failure_flag = MMI_FALSE; /* 021705 Calvin moved from down */
- /* __CUSTPACK_MULTIBIN Calvin END */
- }
- /* 070306 Alpha layer Start */
- /* Find the right extension file name */
- #ifdef __MMI_ALPHA_LAYER_SUPPORT__
- for (j = SUPPORT_N_SEQUENTIAL_IMAGE_TYPE-1; j >= 0; j--)//search from PNG
- #else
- for (j = 0; j < SUPPORT_N_SEQUENTIAL_IMAGE_TYPE; j++)//search from BMP
- #endif
- /* 070306 Alpha layer End */
- {
- itoa(0, number_string, 10);
- extension_type = -1;
- strcpy(autofilename_buffer, filename_buffer);
- strcat(autofilename_buffer, "\\");
- /* strcat(autofilename_buffer,output_image_names); */
- strcat(autofilename_buffer, number_string);
- strcat(autofilename_buffer, ".");
- strcat(autofilename_buffer, sequential_image[j].filename_ext);
- image_data_file = fopen(autofilename_buffer, "rb");
- if (image_data_file != NULL)
- {
- failure_flag = MMI_TRUE;
- extension_type = sequential_image[j].file_type;
- staticFlag = 0;
- *pType = (U16) extension_type;
- sequential_extension_type = j; /* 031705 Calvin modified */
- fclose(image_data_file);
- break;
- }
- }
- // __CUSTPACK_MULTIBIN Calvin BEGIN
- //failure_flag = MMI_FALSE;//021705 Calvin moved to up
- // __CUSTPACK_MULTIBIN Calvin END
- }
- else
- {
- /* patch added by vikram for getting image file size */
- fseek(image_data_file, 0, SEEK_END);
- nImageSize = ftell(image_data_file);
- fseek(image_data_file, 0, SEEK_SET);
- }
- if ((failure_flag == MMI_TRUE) && !(staticFlag))
- {
- /* Sequence found */
- /* Find how many files are in sequence */
- j = 0;
- sequence_counter = 0;
- n_frames = 0;
- while (1)
- {
- itoa(j, number_string, 10);
- strcpy(autofilename_buffer, "");
- strcpy(autofilename_buffer, filename_buffer);
- strcat(autofilename_buffer, "\\");
- /* strcat(autofilename_buffer,output_image_names); */
- strcat(autofilename_buffer, number_string);
- strcat(autofilename_buffer, ".");
- strcat(autofilename_buffer, sequential_image[sequential_extension_type].filename_ext); /* 031705 Calvin modified */
- image_data_file = fopen(autofilename_buffer, "rb");
- if (image_data_file != NULL)
- {
- sequence_counter++;
- fseek(image_data_file, 0, SEEK_END);
- sequential_filesize[j] = ftell(image_data_file);
- fseek(image_data_file, 0, SEEK_SET);
- fclose(image_data_file);
- }
- else
- { /* Sequence complete */
- if (j > 0)
- {
- break;
- }
- }
- j++;
- }
- /* read during */
- {
- int i;
- strcpy(autofilename_buffer, filename_buffer);
- strcat(autofilename_buffer, "\\interval.txt");
- /* 070306 interval missing Start */
- image_data_file = NULL;
- image_data_file = fopen(autofilename_buffer, "r");
- if (image_data_file == NULL)
- {
- printf("ERROR: Can't find %sn", autofilename_buffer);
- staticFlag = 1;
- failure_flag = MMI_FALSE;
- }
- else
- {
- for (i = 0; i < sequence_counter; i++)
- {
- if (fscanf(image_data_file, "%d", &sequential_interval[i]) != 1)
- {
- printf("ERROR: %s, interval [%d] value missing!!n", autofilename_buffer, i);
- staticFlag = 1;
- failure_flag = MMI_FALSE;
- break;
- }
- }
- }
- if (image_data_file != NULL)
- {
- fclose(image_data_file);
- }
- /* 070306 interval missing End */
- }
- /* 070306 interval missing Start */
- if(!staticFlag)
- {
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- itoa(0, number_string, 10);
- strcpy(autofilename_buffer, "");
- strcpy(autofilename_buffer, filename_buffer);
- strcat(autofilename_buffer, "\\");
- strcat(autofilename_buffer, number_string);
- strcat(autofilename_buffer, ".");
- strcat(autofilename_buffer, sequential_image[sequential_extension_type].filename_ext); /* 031705 Calvin modified */
- enfb_ret = Image_Test(autofilename_buffer, &enfb_width, &enfb_height);
- if (enfb_ret!= ENFB_IMAGE_NONE)
- {
- enfbFlag = 1;
- if (enfb_ret == ENFB_IMAGE_ASSOCIATE)
- {
- ENFBAssociatedIDAdded = MMI_TRUE;
- }
- }
- //printf("sequential %s --> %d x %dn", autofilename_buffer, enfb_width, enfb_height);
- #endif
- /* 100206 ENFB support Start */
- /* n_frames=sequence_counter; */
- sequential_frame = sequence_counter;
- /* Construct the data structure name */
- strcpy(autoimagename_buffer, output_image_names);
- strcat(autoimagename_buffer, OUTPUT_IMAGE_NAMES_END);
- fprintf(output_data_file, "__align(4) const U8 ");
- fprintf(output_data_file, autoimagename_buffer);
- Write_Sequential_Image_Header(output_data_file, sequential_image[sequential_extension_type].file_type, sequential_frame, sequential_filesize, sequential_offset); /* 031705 Calvin modified */
- /* Load all files in the sequence */
- j = 0;
- sequence_counter = 0;
- while (1)
- {
- itoa(j, number_string, 10);
- strcpy(autofilename_buffer, "");
- strcpy(autofilename_buffer, filename_buffer);
- strcat(autofilename_buffer, "\\");
- /* strcat(autofilename_buffer,output_image_names); */
- strcat(autofilename_buffer, number_string);
- strcat(autofilename_buffer, ".");
- strcat(autofilename_buffer, sequential_image[sequential_extension_type].filename_ext); /* 031705 Calvin modified */
- image_data_file = fopen(autofilename_buffer, "rb");
- if (image_data_file != NULL)
- {
- Write_Sequential_Image_File(output_data_file, image_data_file, sequential_filesize[j]);
- sequence_counter++;
- fclose(image_data_file);
- }
- else
- { /* Sequence complete */
- if (j > 0)
- {
- break;
- }
- }
- j++;
- }
- fprintf(output_data_file, "n};n");
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- enfbFlag = 0;
- #endif
- /* 100206 ENFB support Start */
- }
- /* 070306 interval missing End */
- } /* End of Animated image processor block */
- if ((failure_flag == MMI_TRUE) && (staticFlag))
- {
- /* Currently assuming that all single files are BMP */
- if (nImageSize == 0)
- {
- image_identifier = IMAGE_TYPE_INVALID; /* 031705 Calvin modified */
- }
- else
- {
- /* MTK Leo add, for read images with same filename but different in ".bmp" and ".gif" */
- image_identifier = ExtractExtension(filename_buffer, RES_IMAGE); /* 101205 audio resource Calvin */
- }
- /* To be changed later for multiple file types */
- *pType = ExtractExtension(filename_buffer, RES_IMAGE); /* 101205 audio resource Calvin */
- /* MTK Leo end */
- /* Load the data */
- /* Construct the data structure name */
- strcpy(autoimagename_buffer, output_image_names);
- strcat(autoimagename_buffer, OUTPUT_IMAGE_NAMES_END);
- if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
- image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
- image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
- image_identifier == IMAGE_TYPE_SWFLASH)
- {
- fprintf(output_data_file, "__align(4) const U8 ");
- }
- else
- {
- fprintf(output_data_file, "const U8 ");
- }
- fprintf(output_data_file, autoimagename_buffer);
- fseek(image_data_file, 0, SEEK_END);
- if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
- image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
- image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
- image_identifier == IMAGE_TYPE_SWFLASH)
- {
- file_size1 = file_size1 + ftell(image_data_file) + 8;
- }
- else
- {
- file_size1 = file_size1 + ftell(image_data_file) + 6;
- }
- fseek(image_data_file, 0, SEEK_SET);
- pBuffer = (U8*) malloc(file_size1);
- if (pBuffer == NULL)
- {
- /* Add Debug Message */
- }
- pBuffer1 = pBuffer;
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- enfb_ret = Image_Test(filename_buffer, &enfb_width, &enfb_height);
- if (enfb_ret != ENFB_IMAGE_NONE)
- {
- enfbFlag = 1;
- if (enfb_ret == ENFB_IMAGE_ASSOCIATE)
- {
- ENFBAssociatedIDAdded = MMI_TRUE;
- }
- }
- #endif
- /* 100206 ENFB support End */
- g_ressize = Load_Image_Data(&image_offset, output_data_file, image_data_file, pBuffer1, image_identifier, 0);
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- enfbFlag = 0;
- #endif
- /* 100206 ENFB support Start */
- //printf("load_image_datan");//070306 Alpha layer
- if (ExtImageFlag == NFB_PROGRESS_IMAGE)
- {
- printf("NFB_PROGRESS_IMAGEn");
- if (nfb_img_res_file != NULL)
- {
- printf("nfb_img_res_filen");
- fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
- fclose(nfb_img_res_file);
- }
- else
- {
- printf("nfb_img_res_file not openedn");
- }
- }
- free(pBuffer);
- fprintf(output_data_file, "n };n");
- fclose(image_data_file);
- }
- }
- /* 120704 Calvin added for populating with .bmp or .gif but actually extsion name is not */
- if (failure_flag == MMI_FALSE)
- {
- /* printf("*************failed !!!********************n"); */
- for (j = 0; j < SUPPORT_N_MEDIA_TYPE; j++)
- {
- S32 l;
- for (l = 0; l < 3; l++)
- {
- filename_buffer[filenameLen - 1 - l] = support_media_ext[j][2 - l];
- }
- /* printf("%s__%sn", support_media_ext[j], filename_buffer); */
- image_data_file = fopen(filename_buffer, "rb");
- if (image_data_file != NULL)
- {
- break;
- }
- }
- if (image_data_file != NULL)
- {
- failure_flag = MMI_TRUE;
- /* printf("got %s n", filename_buffer); */
- fseek(image_data_file, 0, SEEK_END);
- nImageSize = ftell(image_data_file);
- fseek(image_data_file, 0, SEEK_SET);
- /* Currently assuming that all single files are BMP */
- if (nImageSize == 0)
- {
- image_identifier = IMAGE_TYPE_INVALID; /* 031705 Calvin modified */
- }
- else
- {
- /* MTK Leo add, for read images with same filename but different in ".bmp" and ".gif" */
- image_identifier = ExtractExtension(filename_buffer, RES_IMAGE); /* 101205 audio resource Calvin */
- }
- /* To be changed later for multiple file types */
- *pType = ExtractExtension(filename_buffer, RES_IMAGE); /* 101205 audio resource Calvin */
- /* MTK Leo end */
- /* Load the data */
- /* Construct the data structure name */
- strcpy(autoimagename_buffer, output_image_names);
- strcat(autoimagename_buffer, OUTPUT_IMAGE_NAMES_END);
- if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
- image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
- image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
- image_identifier == IMAGE_TYPE_SWFLASH)
- {
- fprintf(output_data_file, "__align(4) const U8 ");
- }
- else
- {
- fprintf(output_data_file, "const U8 ");
- }
- fprintf(output_data_file, autoimagename_buffer);
- fseek(image_data_file, 0, SEEK_END);
- if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
- image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
- image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
- image_identifier == IMAGE_TYPE_SWFLASH)
- {
- file_size1 = file_size1 + ftell(image_data_file) + 8;
- }
- else
- {
- file_size1 = file_size1 + ftell(image_data_file) + 6;
- }
- fseek(image_data_file, 0, SEEK_SET);
- pBuffer = (U8*) malloc(file_size1);
- if (pBuffer == NULL)
- {
- /* Add Debug Message */
- }
- pBuffer1 = pBuffer;
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- enfb_ret = Image_Test(filename_buffer, &enfb_width, &enfb_height);
- if (enfb_ret != ENFB_IMAGE_NONE)
- {
- enfbFlag = 1;
- if (enfb_ret == ENFB_IMAGE_ASSOCIATE)
- {
- ENFBAssociatedIDAdded = MMI_TRUE;
- }
- }
- #endif
- /* 100206 ENFB support End */
- g_ressize = Load_Image_Data(&image_offset, output_data_file, image_data_file, pBuffer1, image_identifier, 0);
- /* 100206 ENFB support Start */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- enfbFlag = 0;
- #endif
- /* 100206 ENFB support End */
- //printf("load_image_datan");//070306 Alpha layer
- if (ExtImageFlag == NFB_PROGRESS_IMAGE)
- {
- printf("NFB_PROGRESS_IMAGEn");
- if (nfb_img_res_file != NULL)
- {
- printf("nfb_img_res_filen");
- fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
- fclose(nfb_img_res_file);
- }
- else
- {
- printf("nfb_img_res_file not openedn");
- }
- }
- free(pBuffer);
- fprintf(output_data_file, "n };n");
- fclose(image_data_file);
- }
- }
- /* Calvin end */
- if (image_data_file != NULL)
- {
- fclose(image_data_file);
- }
- if (output_data_file != NULL)
- {
- fclose(output_data_file);
- }
- return failure_flag;
- }
- /* 101205 audio resource Calvin Satrt */
- /*****************************************************************************
- * FUNCTION
- * Aload
- * DESCRIPTION
- * Load the file audio to buffer and writes to CustAdoRes.c
- * PARAMETERS
- * string [IN] -> string containing file name and path
- * pType [OUT] -> Audio Type
- * RETURNS
- * void* --> buffer containing Audio data
- *****************************************************************************/
- MMI_BOOL Aload(S8 *string, PU16 pType)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 audio_offset = 0;
- U8 *pBuffer = NULL;
- S32 j, n_frames;
- MMI_BOOL failure_flag;
- U8 audio_identifier;
- S32 file_size1 = 0;
- S32 file_size = 0;
- S32 nAudioSize = 0;
- U8 *pBuffer1 = NULL;
- U8 staticFlag = 1; /* Non animated audio */
- /* S8 tempDestFile[] = {"TEMPAUDIO"}; */
- int ret = 1;
- /* S8 tempCommand[200]; */
- size_t size;
- U32 o = 0;
- S16 filenameLen;
- char *curr_output_data_filename;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_ressize = 0;
- if (ExtAudioFlag == TRUE) /* 040805 CustPack: Calvin added */
- {
- curr_output_data_filename = AUDIO_OUTPUT_DATA_FILENAME_EXT;
- }
- else
- {
- curr_output_data_filename = AUDIO_OUTPUT_DATA_FILENAME;
- }
- if (toolFlag == 1)
- { /* 040805 CustPack: Calvin added */
- curr_output_data_filename = "temp";
- }
- strcpy(filename_buffer, curr_output_data_filename); /* 040805 CustPack: Calvin modified */
- output_data_file = fopen(filename_buffer, "ab");
- while (!output_data_file)
- {
- Sleep(50);
- output_data_file = fopen(filename_buffer, "ab");
- }
- output_audio_names = (S8*) malloc(100);
- strcpy(filename_buffer, string);
- if (!(strcmp(filename_buffer, "")))
- {
- strcpy(filename_buffer, NOAUDIO_FILENAMEBUFFER);
- }
- Extract_Name(output_audio_names, filename_buffer, RES_AUDIO);
- failure_flag = MMI_TRUE;
- filenameLen = strlen(filename_buffer);
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- {
- audio_data_file = fopen(filename_buffer, "rb");
- if (audio_data_file == NULL)
- {
- /* Add extension add search */
- FILE *fail = fopen("fail.txt", "a+");
- if (fail != NULL)
- {
- if (toolFlag == 0) /* 040805 CustPack: Calvin modified */
- {
- fprintf(fail, "%sn", filename_buffer);
- fclose(fail);
- }
- failure_flag = MMI_FALSE; /* 021705 Calvin moved from down */
- }
- }
- else
- {
- /* patch added by vikram for getting audio file size */
- fseek(audio_data_file, 0, SEEK_END);
- nAudioSize = ftell(audio_data_file);
- fseek(audio_data_file, 0, SEEK_SET);
- }
- if ((failure_flag == MMI_TRUE) && (staticFlag))
- {
- /* Currently assuming that all single files are BMP */
- if (nAudioSize == 0)
- {
- audio_identifier = AUDIO_TYPE_INVALID; /* 031705 Calvin modified */
- }
- else
- {
- /* MTK Leo add, for read audios with same filename but different in ".bmp" and ".gif" */
- audio_identifier = ExtractExtension(filename_buffer, RES_AUDIO); /* 101205 audio resource Calvin */
- }
- /* To be changed later for multiple file types */
- *pType = ExtractExtension(filename_buffer, RES_AUDIO); /* 101205 audio resource Calvin */
- /* Load the data */
- /* Construct the data structure name */
- strcpy(autoimagename_buffer, output_audio_names);
- strcat(autoimagename_buffer, OUTPUT_AUDIO_NAMES_END);
- fprintf(output_data_file, "__align(4) const U8 ");
- fprintf(output_data_file, autoimagename_buffer);
- fseek(audio_data_file, 0, SEEK_END);
- file_size1 = file_size1 + ftell(audio_data_file) + 8;
- fseek(audio_data_file, 0, SEEK_SET);
- pBuffer = (U8*) malloc(file_size1);
- if (pBuffer == NULL)
- {
- /* Add Debug Message */
- }
- pBuffer1 = pBuffer;
- g_ressize = Load_Audio_Data(&audio_offset, output_data_file, audio_data_file, pBuffer1, audio_identifier);
- free(pBuffer);
- fprintf(output_data_file, "n };n");
- fclose(audio_data_file);
- }
- }
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- if (audio_data_file != NULL)
- {
- fclose(audio_data_file);
- }
- if (output_data_file != NULL)
- {
- fclose(output_data_file);
- }
- return failure_flag;
- }
- /* 101205 audio resource Calvin End */
- /*****************************************************************************
- * FUNCTION
- * ClearHWIMageFile
- * DESCRIPTION
- * Clear image file
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClearHWIMageFile()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE *fp;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- fp = fopen(OUTPUT_DATA_FILENAME, "w+");
- if (fp)
- {
- fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
- fclose(fp);
- }
- /* __CUSTPACK_MULTIBIN Calvin BEGIN */
- fp = fopen(OUTPUT_DATA_FILENAME_EXT, "w+"); /* 040805 CustPack: Calvin added */
- /* __CUSTPACK_MULTIBIN Calvin END */
- if (fp)
- {
- fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
- fclose(fp);
- }
- /* 101205 audio resource Calvin Satrt */
- fp = fopen(AUDIO_OUTPUT_DATA_FILENAME, "w+");
- if (fp)
- {
- fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
- fclose(fp);
- }
- fp = fopen(AUDIO_OUTPUT_DATA_FILENAME_EXT, "w+");
- if (fp)
- {
- fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
- fclose(fp);
- }
- /* 101205 audio resource Calvin End */
- /* 100206 ENFB support Satrt */
- #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
- enfb_img_data_file = fopen(ENFB_IMAGE_DATA_FILENAME, "w+");
- if (enfb_img_data_file)
- {
- fclose(enfb_img_data_file);
- }
- enfb_img_data_file = fopen(ENFB_IMAGE_DATA_FILENAME, "ab");
- #endif
- /* 100206 ENFB support End */
- }
- #endif /* DEVELOPER_BUILD_FIRST_PASS */
- #if defined(CUSTOMIZATION_BUILD_FIRST_PASS) || defined(CUSTOMIZATION_BUILD_SECOND_PASS)
- CURR_SCREEN_RESOURCE gsCurrScreenInfo;
- extern CUSTOM_MENU nCustMenus[MAX_MENU_ITEMS];
- extern U16 CurrMaxMenuItemIndex;
- /*****************************************************************************
- * FUNCTION
- * SetCurrentScreenStrings
- * DESCRIPTION
- * SEt the current screen strings
- * PARAMETERS
- * nNum [IN] ..
- * RETURNS
- * void
- *****************************************************************************/
- void SetCurrentScreenStrings(U16 nNum, ...)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nId;
- U16 nCount = 0;
- va_list vlist;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- va_start(vlist, nNum);
- gsCurrScreenInfo.nNoOfStrings = nNum;
- while (nNum > nCount)
- {
- nId = va_arg(vlist, U16);
- gsCurrScreenInfo.nStringIdList[nCount] = nId;
- ++nCount;
- }
- va_end(vlist);
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * SetCurrentScreenImages
- * DESCRIPTION
- * SEt the current screen images
- * PARAMETERS
- * nNum [IN] ..
- * RETURNS
- * void
- *****************************************************************************/
- void SetCurrentScreenImages(U16 nNum, ...)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nId;
- U16 nCount = 0;
- va_list vlist;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- va_start(vlist, nNum);
- gsCurrScreenInfo.nNoOfImages = nNum;
- while (nNum > nCount)
- {
- nId = va_arg(vlist, U16);
- gsCurrScreenInfo.nImageIdList[nCount] = nId;
- ++nCount;
- }
- va_end(vlist);
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * AppendCurrentScreenImages
- * DESCRIPTION
- * SEt the current screen images
- * PARAMETERS
- * nNum [IN]
- * pList [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void AppendCurrentScreenImages(int nNum, U16 *pList)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nCount = 0;
- U16 i = 0;
- U8 flag = 0;
- U16 nOrgCount = gsCurrScreenInfo.nNoOfImages;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gsCurrScreenInfo.nNoOfImages = nNum + gsCurrScreenInfo.nNoOfImages;
- while (nNum > nCount)
- {
- flag = 0;
- //for(i = nOrgCount+1;i<(nOrgCount+nCount ) ;i++)
- //for(i = (nOrgCount+nCount);i>0 ;i--)
- for (i = 0; i < nCount; i++)
- {
- if (gsCurrScreenInfo.nImageIdList[i + nOrgCount] == pList[nCount])
- {
- flag = 1;
- break;
- }
- }
- if (flag == 0)
- {
- gsCurrScreenInfo.nImageIdList[nOrgCount + nCount] = pList[nCount];
- }
- ++nCount;
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * AppendCurrentScreenStrings
- * DESCRIPTION
- * SEt the current screen images
- * PARAMETERS
- * nNum [IN]
- * pList [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void AppendCurrentScreenStrings(int nNum, U16 *pList)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nCount = 0;
- U16 nOrgCount = gsCurrScreenInfo.nNoOfStrings;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gsCurrScreenInfo.nNoOfStrings = nNum + gsCurrScreenInfo.nNoOfStrings;
- while (nNum > nCount)
- {
- gsCurrScreenInfo.nStringIdList[nOrgCount + nCount] = pList[nCount];
- ++nCount;
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * SetCurrentScreenMenus
- * DESCRIPTION
- * SEt the current screen menus
- * PARAMETERS
- * nNum [IN] ..
- * RETURNS
- * void
- *****************************************************************************/
- void SetCurrentScreenMenus(U16 nNum, ...)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nId;
- U16 nCount = 0;
- U16 nParentIdCount = 0;
- va_list vlist;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- va_start(vlist, nNum);
- gsCurrScreenInfo.nNoOfMenus = nNum;
- while (nNum > nCount)
- {
- nId = va_arg(vlist, U16);
- gsCurrScreenInfo.sMenuInfo[nCount].nId = nId;
- nParentIdCount = 0;
- while (nParentIdCount > CurrMaxMenuItemIndex)
- {
- if (nCustMenus[nParentIdCount].nMenuItemId == nId)
- {
- gsCurrScreenInfo.sMenuInfo[nCount].nParentId = nCustMenus[nParentIdCount].nParentId;
- break;
- }
- ++nParentIdCount;
- }
- ++nCount;
- }
- va_end(vlist);
- return;
- }
- #endif /* defined(CUSTOMIZATION_BUILD_FIRST_PASS) || defined(CUSTOMIZATION_BUILD_SECOND_PASS) */