int barcode_to_png (char *image_name) { MagickWand *magick_wand; MagickBooleanType status; int width, height, pad, half_pad; /* read a barcode image */ MagickWandGenesis(); magick_wand = NewMagickWand(); MagickSetResolution(magick_wand, 300, 300); status = MagickReadImage(magick_wand, image_name); if (status == MagickFalse) ThrowWandException(magick_wand, 1); /* trim the image, resample it, and pad it by [10% of the long side] per side */ MagickTrimImage(magick_wand, 10); width = MagickGetImageWidth(magick_wand); height = MagickGetImageHeight(magick_wand); pad = determine_padding(width, height); half_pad = round(pad/2); MagickExtentImage(magick_wand, width+pad, height+pad, -half_pad, -half_pad); /* write image (a PNG version and a formatted PS version) */ status=MagickWriteImage(magick_wand, chop_path(image_name, ".png")); if (status == MagickFalse) ThrowWandException(magick_wand, 2); status=MagickWriteImage(magick_wand, chop_path(image_name, ".ps")); if (status == MagickFalse) ThrowWandException(magick_wand, 2); /* clean up */ magick_wand=DestroyMagickWand(magick_wand); MagickWandTerminus(); return 0; }
/*=================================================== * add_path_files_to_proplist -- Add all files on path to list of property tables * Created: 2002/10/19, Perry Rapp *=================================================*/ INT add_path_files_to_proplist (CNSTRING path, SELECT_FNC selectfnc, LIST list) { STRING dirs, p; INT ct=0; if (!path || !path[0]) return 0; dirs = (STRING)stdalloc(strlen(path)+2); chop_path(path, dirs); for (p=dirs; *p; p+=strlen(p)+1) { add_dir_files_to_proplist(p, selectfnc, list); } return ct; }
void edit_qt() //this is used to set the quest template for the current quest { char tpath[2048]; char tpath2[2048]; strcpy(temppath, header.templatepath); if(temppath[0]==0) { getcwd(temppath,2048); fix_filename_case(temppath); fix_filename_slashes(temppath); put_backslash(temppath); } bool gotname; gotname=getname("Load Quest Template (.zqt)","zqt",NULL,temppath,true); if(gotname) { strcpy(tpath, temppath); chop_path(tpath); getcwd(tpath2,2048); fix_filename_case(tpath2); fix_filename_slashes(tpath2); put_backslash(tpath2); if(!strcmp(tpath, tpath2)) { strcpy(header.templatepath, get_filename(temppath)); } else { strcpy(header.templatepath, temppath); } if(!valid_zqt(temppath)) { jwin_alert("ZQuest","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont); memset(header.templatepath, 0, 2048); } } }
void edit_qt(int index) { int ret; quest_template tqt; char tpath[2048]; char tpath2[2048]; tqt=QuestTemplates[index]; editqt_dlg[0].dp2=lfont; do { editqt_dlg[6].dp=QuestTemplates[index].name; editqt_dlg[8].dp=QuestTemplates[index].path; strcpy(temppath, QuestTemplates[index].path); bool gotname; if(is_large) large_dialog(editqt_dlg); ret=zc_popup_dialog(editqt_dlg,6); switch(ret) { case 2: gotname=getname("Load Quest Template (.zqt)","zqt",NULL,temppath,true); if(gotname) { strcpy(tpath, temppath); chop_path(tpath); getcwd(tpath2,2048); fix_filename_case(tpath2); fix_filename_slashes(tpath2); put_backslash(tpath2); if(!strcmp(tpath, tpath2)) { strcpy(QuestTemplates[index].path, get_filename(temppath)); } else { strcpy(QuestTemplates[index].path, temppath); } } break; case 3: if(!valid_zqt(temppath)) { ret=2; jwin_alert("ZQuest","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont); break; } if(index==qt_count) { ++qt_count; } break; case 4: QuestTemplates[index]=tqt; break; } } while(ret==2); }