// 編集中のHTMLファイルと同じフォルダにあるJPEG画像をIMGタグで並べる #include unsigned int calc_offset( unsigned char marker, unsigned int n ); void calc_xy( unsigned char buff[], unsigned int *xp, unsigned int *yp ); listimg { txstr listfile,filepath,filename,command,c,w,h; unsigned int i,top,x,y; HANDLE hf; unsigned char buff[300]; command="c:\\windows\\system32\\cmd.exe"; //環境毎に設定する filepath=text->szfilename; filename=pathGetFileName(filepath); regular(filepath,filename,"",SEARCH_NOSENSECASE); c=strleft(filepath,1); listfile="\""+filepath+"temp.txt"+"\""; command+=" /c dir /b /on /l \""+filepath+"*.jpg\" > "+listfile; CommandExec(command); top=txGetAddress(text); //カーソル位置のテキストアドレス txInsertFile(text,listfile); //テキストファイルの内容を挿入します txSelectEx(text,CLIP_PARA); //範囲選択を開始 txJumpAddress(text,top); //テキストのアドレスへジャンプ txSelectQuit(text); //範囲選択の終了 txWalkStart(text); //範囲内ウォークを開始する while(txIsWalking(text)) { //カーソルが範囲内かどうか返します txGetPara(text,filename); hf=_lopenex_A(filepath+filename,GENERIC_READ,0); //ファイルを開いてファイルハンドル(HANDLE型)を返します _lread(hf,buff,256); //ファイルハンドルのファイルの現在位置からbuffに最大sizeバイト読み込みます _lcloseex(hf); //ファイルハンドルを閉じます calc_xy( buff,&y,&x ); w=inttostr((int)x); h=inttostr((int)y); txInsert(text,""); txNextPara(text); //1つ後ろの段落行の先頭へジャンプ } txWalkEnd(text); //範囲内ウォークを終える fileDelete(listfile); } unsigned int calc_offset( unsigned char marker, unsigned int n ) { unsigned int i; if(marker>=0xe1 && marker<=0xef) { i=2+n; } else { switch( marker ) { case 0xd8: i=2; break; case 0xe0: i=18; break; case 0xdb: i=2+n; break; case 0xc4: i=2+n; break; case 0xc0: i=5; break; default: i=2; break; } } return(i); } void calc_xy( unsigned char buff[], unsigned int *xp, unsigned int *yp ) { unsigned int i; unsigned char mark; mark=0; i=0; while(mark!=0xc0 && i<256) { mark = buff[i+1]; i+=calc_offset(mark,buff[i+2]*256+buff[i+3]); } if(mark==0xc0) { *xp=buff[i]*256+buff[i+1]; *yp=buff[i+2]*256+buff[i+3]; } } // 編集中のHTMLファイルと同じフォルダにあるJPEG画像をIMGタグで並べてキャプションに時間を追記 listimgtime { txstr listfile,filepath,filename,command,c,org_dir; unsigned int i,top; HANDLE fp; WIN32_FIND_DATA lpffd; FILETIME f_local_time; SYSTEMTIME f_time; unsigned char buff[300]; txstr w,h; unsigned int x,y; // command="c:\\winnt\\system32\\cmd.exe"; //環境毎に設定する windows2000 command="c:\\windows\\system32\\cmd.exe"; //環境毎に設定する windows XP filepath=text->szfilename; filename=pathGetFileName(filepath); regular(filepath,filename,"",SEARCH_NOSENSECASE); c=strleft(filepath,1); listfile="\""+filepath+"temp.txt"+"\""; command+=" /c dir /b /on /l \""+filepath+"*.jpg\" > "+listfile; CommandExec(command); top=txGetAddress(text); //カーソル位置のテキストアドレス txInsertFile(text,listfile); //テキストファイルの内容を挿入します txSelectEx(text,CLIP_PARA); //範囲選択を開始 txJumpAddress(text,top); //テキストのアドレスへジャンプ txSelectQuit(text); //範囲選択の終了 txWalkStart(text); //範囲内ウォークを開始する org_dir=filepath; uiSelectFolder(org_dir,"元画像フォルダを指定"); pathSetDir(org_dir); while(txIsWalking(text)) { //カーソルが範囲内かどうか返します txGetWord(text,filename); fp=FindFirstFile(org_dir+filename+".jpg",&lpffd); FindClose(fp); if(fp == INVALID_HANDLE_VALUE) { break; } FileTimeToLocalFileTime(&lpffd.ftLastWriteTime,&f_local_time); FileTimeToSystemTime(&f_local_time,&f_time); fp=_lopenex_A(filepath+filename+".jpg",GENERIC_READ,0); //ファイルを開いてファイルハンドル(HANDLE型)を返します if(fp == INVALID_HANDLE_VALUE) { _lcloseex(fp); break; } _lread(fp,buff,256); //ファイルハンドルのファイルの現在位置からbuffに最大sizeバイト読み込みます _lcloseex(fp); //ファイルハンドルを閉じます calc_xy( buff,&y,&x ); w=inttostr((int)x); h=inttostr((int)y); txInsert(text,"画像タイトル"); txInsertf(text,"%d/%d/%d %d:%02d",f_time.wYear,f_time.wMonth,f_time.wDay,f_time.wHour,f_time.wMinute); txInsert(text,"\n\n"); txNextPara(text); //1つ後ろの段落行の先頭へジャンプ } txWalkEnd(text); //範囲内ウォークを終える fileDelete(listfile); }