/** TGAImage jbxl::readTGAData(FILE* fp) TGAファイルを読み込んで,TGAImage構造体へデータを格納する. @param fp 読み込むファイルの記述子 @return TGAImage データ.gp==NULL の場合,@b state に情報が入る. @retval ERROR_GRAPH_OPFILE @b state: ファイルオープンエラー @retval ERROR_GRAPH_HEADER @b state: 不正ファイル(TGAファイルでない?) @retval ERROR_GRAPH_MEMORY @b state: メモリエラー */ TGAImage jbxl::readTGAData(FILE* fp) { TGAImage tga; fseek(fp, 0, 0); tga.free(); /**********************************************************************/ print_message("**********************************************\n"); print_message("ERROR: jbxl::readTGAData() is not implemeted!!\n"); print_message("**********************************************\n"); tga.state = ERROR_GRAPH_IVDARG; /**********************************************************************/ return tga; }
/** @param texture : コンバート元データのUUID @param add_fname : コンバート先ファイル名の追加文字列 @param ext_fname : コンバート先ファイル名の拡張子 @param dist : コンバート先のパス @param comformat : 内部処理が失敗した場合の外部処理コマンド.NULL の場合はデフォルトを使用する. */ void OARTool::ConvertTexture(const char* texture, const char* add_name, const char* ext_name, const char* dist, const char* comformat) { if (texture==NULL) return; Buffer outpath; if (dist==NULL) outpath = make_Buffer_bystr((char*)pathTEX.buf); else outpath = make_Buffer_bystr(dist); bool converted = false; cat_s2Buffer(texture, &outpath); if (add_name!=NULL) { cat_s2Buffer("_", &outpath); cat_s2Buffer(add_name, &outpath); if (ext_name!=NULL) { if (ext_name[0]!='.') cat_s2Buffer(".", &outpath); cat_s2Buffer(ext_name, &outpath); } } rewrite_sBuffer_str(&outpath, " ", "\\ "); rewrite_sBuffer_str(&outpath, ";", "\\;"); if (!file_exist((char*)outpath.buf)) { Buffer inppath = make_Buffer_bystr(texture); rewrite_sBuffer_str(&inppath, " ", "\\ "); rewrite_sBuffer_str(&inppath, ";", "\\;"); free_Buffer(&inppath); char* path = get_resource_path((char*)texture, assetsFiles); char* extn = get_file_extension(path); // if (path!=NULL && extn!=NULL && (extn[0]=='j' || extn[0]=='J')) { // for Jpeg2000 // JPEG2KImage jpg = readJPEG2KFile(path); if (jpg.state==0) { MSGraph<uByte> vp = JPEG2KImage2MSGraph<uByte>(jpg); DEBUG_MODE print_message("OARTool::ConvertTexture: texture = %s [size = (%4d,%4d,%2d), mode = %d]\n", texture, jpg.ws, jpg.hs, jpg.col, jpg.cmode); // if (vp.zs>0) { TGAImage tga = MSGraph2TGAImage(vp); int err = writeTGAFile((char*)outpath.buf, tga); if (!err) converted = true; else print_message("OARTool::ConvertTexture: ERROR: write error (%d).\n", err); tga.free(); } else { print_message("OARTool::ConvertTexture: ERROR: color num of %s is %d\n", texture, vp.zs); } vp.free(); jpg.free(); } else { if (jpg.state==ERROR_GRAPH_IVDDATA) { DEBUG_MODE print_message("OARTool::ConvertTexture: ERROR: texture %s is invalid.\n", texture); } else { DEBUG_MODE print_message("OARTool::ConvertTexture: ERROR: texture %s convert error (%d).\n", texture, jpg.state); } } // Retry convert using external command if (!converted) { DEBUG_MODE print_message("OARTool::ConvertTexture: RETRY: convert %s to %s\n", path, (char*)outpath.buf); // char command[LDATA]; memset(command, 0, LDATA); if (comformat!=NULL) { snprintf(command, LDATA-1, comformat, path, (char*)outpath.buf); } else { snprintf(command, LDATA-1, OART_JP2_DECOMP_COM, path, (char*)outpath.buf); } int ret = system(command); int err = WEXITSTATUS(ret); if (err!=0) print_message("OARTool::ConvertTexture: ERROR: texture %s convert error (%d, %d).\n", texture, jpg.state, err); else DEBUG_MODE print_message("OARTool::ConvertTexture: SUCCESS: texture %s is converted.\n", texture); } } else { print_message("OARTool::ConvertTexture: ERROR: texture %s is lost!\n", texture); } } free_Buffer(&outpath); return; }