EXPORT BOOL WINAPI mhsp_SWFBitmap_buf(HSPEXINFO *hei, int p2, int p3, int p4) { unsigned char *buf, *buf2; int size, size2; SWFInput input; SWFBitmap *p1; lstrcpy(funcname, "SWFBitmap_buf"); p1 = (SWFBitmap *)hei->HspFunc_prm_getv(); buf = (unsigned char *)hei->HspFunc_prm_getv(); size = hei->HspFunc_prm_geti(); buf2 = (unsigned char *)hei->HspFunc_prm_getv(); size2 = hei->HspFunc_prm_getdi(0); input = newSWFInput_allocedBuffer(buf, size); if (size2 && isJPEG(input)) { SWFInput_seek(input, 0, SEEK_SET); *p1 = (SWFBitmap)newSWFJpegWithAlpha_fromInput(input, newSWFInput_allocedBuffer(buf2, size2)); } #ifdef JAMING else if (isDBL(input) || isJPEG(input)) #else else if (isDBL(input) || isJPEG(input) || isGIF(input) || isPNG(input) || isBMP(input)) #endif { SWFInput_seek(input, 0, SEEK_SET); *p1 = newSWFBitmap_fromInput(newSWFInput_allocedBuffer(buf, size)); } else { return -1; } if (!mhsp_bitmap) { mhsp_bitmap = *p1; } return 0; }
int ReadDir(const char *dir) { int file_count = 0; int temp = 0; struct dirent* ptr; DIR* srcdir = opendir(dir); if (srcdir == NULL) { perror("opendir"); return -1; } while((ptr = readdir(srcdir)) != NULL) // traverse done { char* d_name; d_name = ptr -> d_name; printf("\n/////////////////////////START SCANNING//////////////////////////\n"); // Open catlog.csv file FILE* fp; char html_path[100] = {}; sprintf(html_path, "%s/%s/%s", getcwd(NULL, 0), inputdir, "catlog.csv"); fp = fopen(html_path, "w"); // Open directory if (ptr -> d_type & DT_DIR) // check whether it is a directory { if(strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) { char path[100]; sprintf(path, "%s/%s", dir, d_name); temp = ReadDir(path); file_count += temp; } }else{ // Check if the type matchs if (isPNG(d_name) || isGIF(d_name) || isTIFF(d_name)){ fseek(fp, 0L, SEEK_END); int sz = ftell(fp); fseek(fp, 0L, SEEK_SET); fprintf(fp, }else{ printf("The file is not png/gif/tiff file, skipped it.\n"); } }
ImageType getImageType(const std::string& FileName) { FILE *file_image = fopen(FileName.c_str(), "rb"); if (!file_image) { //file could not be opened for reading return itUnknown; } unsigned char header[8]; memset(header, 0, 8); //read first eight bytes if (fread(header, 1, 8, file_image)!=8) { //file is not long enough to be a proper image file fclose(file_image); return itUnknown; } fclose(file_image); if (isJPEG(header, 8)) { return itJPEG; } if (isPNG(header, 8)) { return itPNG; } if (isGIF(header, 8)) { return itGIF; } if (isPPM(header, 8)) { return itPPM; } if (isBMP(header, 8)) { return itBitmap; } return itUnknown; }
EXPORT BOOL WINAPI mhsp_SWFBitmap(HSPEXINFO *hei, int p2, int p3, int p4) { FILE *fp1, *fp2; char filename[MHSP_STRMAX], alpha[MHSP_STRMAX]; SWFInput input; SWFBitmap *p1; lstrcpy(funcname, "SWFBitmap"); p1 = (SWFBitmap *)hei->HspFunc_prm_getv(); lstrcpyn(filename, hei->HspFunc_prm_gets(), MHSP_STRMAX); lstrcpyn(alpha, hei->HspFunc_prm_getds(""), MHSP_STRMAX); fp1 = fopen(filename, "rb"); if (!fp1) { return 1; } input = newSWFInput_file(fp1); fp2 = fopen(alpha, "rb"); if (fp2 && isJPEG(input)) { SWFInput_seek(input, 0, SEEK_SET); *p1 = (SWFBitmap)newSWFJpegWithAlpha_fromInput(input, newSWFInput_file(fp2)); } #ifdef JAMING else if (isDBL(input) || isJPEG(input)) #else else if (isDBL(input) || isJPEG(input) || isGIF(input) || isPNG(input) || isBMP(input)) #endif { SWFInput_seek(input, 0, SEEK_SET); *p1 = newSWFBitmap_fromInput(input); } else { return -1; /* 非対応フォーマット */ } if (!mhsp_bitmap) { mhsp_bitmap = *p1; } return 0; }