home *** CD-ROM | disk | FTP | other *** search
- function GeneratePreview(cSourcePath, cDestPath, cID)
- {
- //MessageBox("cSourcePath = " + cSourcePath + "\ncDestPath = " + cDestPath + "\ncID = " + cID, "Preview", MB_OK);
- }
-
- function GetPageFN(iPage) {
- if (iPage == 1) {
- return "index.htm";
- }
-
- return "page" + IntToStr(iPage, 5) + ".htm";
- }
-
- var iThnWidth = 160;
- var iThnHeight = 120;
- var rcThn;
-
- function ProcessImage(pImg, pDestImg) {
- pImg.Resize(rcThn.Width()-4, rcThn.Height()-4, GFX_KEEP_ASPECT | GFX_INTERPOLATE);
- var rcResized = pImg.GetRect();
-
- pImg.Shadow(iShadowColor, iShadowAlpha*2.55, iShadowXOffset, iShadowYOffset, iShadowBlur, 0);
-
- //pImg.Resize(rcThn.Width(), rcThn.Height(), GFX_KEEP_ASPECT | GFX_INTERPOLATE);
- var rcResized = pImg.GetRect();
-
- var fAngle = Math.random()*fMaxAngle*2-fMaxAngle;
- pImg.Rotate(fAngle, 0, GFX_INTERPOLATE);
-
- var rcImg = pImg.GetRect();
-
- var iOffsetX = (iThnWidth - rcImg.Width()) / 2;
- var iOffsetY = (iThnHeight - rcImg.Height()) / 2;
-
- pImg.Draw(pDestImg, rcImg, iOffsetX, iOffsetY, 255, GFX_KEEP_ALPHA);
-
- return GetRotatedImageMap(rcResized, fAngle, iOffsetX, iOffsetY);
- }
-
- function GenerateAlbum(cSourcePath, cDestPath)
- {
- rcThn = CalcRectBeforeRotate(fMaxAngle, iThnWidth, iThnHeight);
-
- var iFilesCount = lSelectedFiles.GetCount();
-
- var iPagesCount = Math.ceil(iFilesCount / 9);
-
- CopyFile(cSourcePath + "0101.jpg", cDestPath + "0101.jpg", FIL_OM_OVERWRITE);
-
- CopyFile(cSourcePath + "0201.jpg", cDestPath + "0201.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0203.jpg", cDestPath + "0203.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0205.jpg", cDestPath + "0205.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0207.jpg", cDestPath + "0207.jpg", FIL_OM_OVERWRITE);
-
- CopyFile(cSourcePath + "0301.jpg", cDestPath + "0301.jpg", FIL_OM_OVERWRITE);
-
- CopyFile(cSourcePath + "0401.jpg", cDestPath + "0401.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0403.jpg", cDestPath + "0403.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0405.jpg", cDestPath + "0405.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0407.jpg", cDestPath + "0407.jpg", FIL_OM_OVERWRITE);
-
- CopyFile(cSourcePath + "0501.jpg", cDestPath + "0501.jpg", FIL_OM_OVERWRITE);
-
- CopyFile(cSourcePath + "0601.jpg", cDestPath + "0601.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0603.jpg", cDestPath + "0603.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0605.jpg", cDestPath + "0605.jpg", FIL_OM_OVERWRITE);
- CopyFile(cSourcePath + "0607.jpg", cDestPath + "0607.jpg", FIL_OM_OVERWRITE);
-
- CopyFile(cSourcePath + "0701.jpg", cDestPath + "0701.jpg", FIL_OM_OVERWRITE);
-
- var tPage = new CTemplate();
- tPage.Load(cSourcePath + "page.tpl", 0);
-
- tPage.SetReplace("${TITLE}", cTitle);
- tPage.SetReplace("${HEAD_FONT_SIZE}", iHeaderFontSize);
- tPage.SetReplace("${HEAD_FONT_COLOR}", HEXColor(iHeaderFontColor));
- tPage.SetReplace("${FOOT_FONT_SIZE}", iFooterFontSize);
- tPage.SetReplace("${FOOT_FONT_COLOR}", HEXColor(iFooterFontColor));
- tPage.SetReplace("${HEADER}", ReplaceExifStrings(cHeader, "", ""));
- tPage.SetReplace("${FOOTER}", ReplaceExifStrings(cFooter, "", ""));
-
- var tImg = new CTemplate();
- tImg.Load(cSourcePath + "img.tpl", 0);
-
- var tNoImg = new CTemplate();
- tNoImg.Load(cSourcePath + "noimg.tpl", 0);
-
- var tMap = new CTemplate();
- tMap.Load(cSourcePath + "map.tpl", 0);
-
- var iPage = 1;
- var iImg = 1;
- var cMaps = "";
-
- for (var iFile = 1; ((iFile <= iFilesCount) || (iImg != 1)); iFile++) {
- if (iFile <= iFilesCount) {
-
- var cFileName = lSelectedFiles.GetAt(iFile-1);
- var cImgFileName = "img" + IntToStr(iFile, 5) + ".jpg";
- var cThnFileName = "thn" + IntToStr(iPage, 3) + "-" + iImg + ".jpg";
- var cMapName = "imgMap" + iImg;
-
- var pOrigImg = new CImage();
- pOrigImg.Load(cFileName, 0);
-
- pOrigImg.Resize(iImgWidth, iImgHeight, GFX_KEEP_ASPECT | GFX_INTERPOLATE);
- pOrigImg.SaveAs(cDestPath + cImgFileName, JPGformat, iImgJPEG, 0);
-
- var pImg = new CImage();
- pImg.Load(cSourcePath + "img" + iImg + ".jpg", 0);
- var cMapCoords = ProcessImage(pOrigImg, pImg);
- pImg.SaveAs(cDestPath + cThnFileName, JPGformat, iTNJPEG, 0);
-
- tMap.SetReplace("${MAP_NAME}", cMapName);
- tMap.SetReplace("${MAP_HREF}", cImgFileName);
- tMap.SetReplace("${MAP_COORDS}", cMapCoords);
- cMaps += tMap.Replace();
-
- tImg.SetReplace("${THN_FILENAME}", cThnFileName);
- tImg.SetReplace("${THN_MAPNAME}", cMapName);
-
- tPage.SetReplace("${IMG"+iImg+"}", tImg.Replace());
-
- pImg.Close();
- pOrigImg.Close();
-
- } else { // no other files to process, make table complete
- var cThnFileName = "thn" + IntToStr(iPage, 3) + "-" + iImg + ".jpg";
- CopyFile(cSourcePath + "img" + iImg + ".jpg", cDestPath + cThnFileName, FIL_OM_OVERWRITE);
- tNoImg.SetReplace("${THN_FILENAME}", cThnFileName);
-
- tPage.SetReplace("${IMG"+iImg+"}", tNoImg.Replace());
- }
-
- iImg++;
-
- if (iImg > 9) {
- if (iPage > 1) {
- tPage.SetReplace("${PREV}", " <a href=\""+GetPageFN(iPage-1)+"\"><<</a>");
- } else {
- tPage.SetReplace("${PREV}", " ");
- }
- if (iPage < iPagesCount) {
- tPage.SetReplace("${NEXT}", "<a href=\""+GetPageFN(iPage+1)+"\">>></a> ");
- } else {
- tPage.SetReplace("${NEXT}", " ");
- }
- tPage.SetReplace("${MAPS}", cMaps);
- SaveString(cDestPath + GetPageFN(iPage), tPage.Replace(), 0);
-
- cMaps = "";
- iImg = 1;
-
- iPage++;
- }
-
- }
-
- return cDestPath + GetPageFN(1);
-
- }
-
- INIT_OK;
-