Camera 1 Sunday, take a shot (Tokyo)
Camera 2 Sunday, take a shot (Paris)
Camera 3 Sunday, take a shot (Newyork)
shared 1, 2, and 3. but filename ???
Let's culture share !
CS_0001.JPG Tokyo
CS_0002.JPG Newyork
CS_0003.JPG Tokyo
CS_0004.JPG Paris
But... world wide user must use world time

Code: Select all
; Culture share
;
; some camera shared to sync exif time, and chage to unified filename
;
; copyright hiroyuki yokota (oryaaaaa) 2013/11/19 17:39
Structure FileS
name.s
date.l
EndStructure
Enumeration
#WindowMain
EndEnumeration
Enumeration
#T_name
#B_folder
#B_start
#T_filepath
#T_jpgfile
EndEnumeration
Global NewList sync.FileS()
Global *imageAdress = AllocateMemory(8192)
Procedure.s OSlocale()
Protected localedata.s, RETlocale.l
localedata=Space(256)
RETlocale= GetLocaleInfo_($400, $1001, localedata, Len(localedata))
localedata=Left(localedata, RETlocale-1)
ProcedureReturn localedata
; English , Japanese , etc
EndProcedure
Procedure DefaultFontLoad()
; this code is for Japan, Korea, and China
Shared fnt1.l, fnt2.l
Protected hdc.I, hDpi.I, ScreenDpi.f, finfo.LOGFONT, fnt.l, systemfontname.s
hdc = GetDC_(GetDesktopWindow_())
If hdc
hDpi = GetDeviceCaps_(hdc, #LOGPIXELSX)
ReleaseDC_(GetDesktopWindow_(), hdc)
ScreenDpi = 96/hDpi
Else
ScreenDpi = 1.0
EndIf
fnt =GetStockObject_(#DEFAULT_GUI_FONT)
If fnt
GetObject_(fnt,SizeOf(LOGFONT),@finfo)
systemfontname = PeekS(@finfo\lfFaceName[0])
Else
systemfontname ="System"
EndIf
fnt1 = LoadFont(#PB_Any, systemfontname, Round(36*ScreenDpi, #PB_Round_Down))
fnt2 = LoadFont(#PB_Any, systemfontname, Round(14*ScreenDpi, #PB_Round_Down))
EndProcedure
Procedure OpenWindow_main()
Shared fnt1.l, fnt2.l
Shared window_flg.b
If OpenWindow(#WindowMain, 0, 0, 800, 200, "Culture share", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered )
window_flg = #True
UseGadgetList(#WindowMain)
SetWindowColor(#WindowMain, $711A00)
StringGadget(#T_name, 10, 10, 500, 50, "CS_", #PB_String_UpperCase)
SetGadgetFont(#T_name, FontID(fnt1))
TextGadget(#T_jpgfile, 550,10, 200, 25, "CS_0048.JPG", #PB_Text_Center)
SetGadgetFont(#T_jpgfile, FontID(fnt2))
ButtonGadget(#B_folder, 10, 70, 400, 50, "select folders")
SetGadgetFont(#B_folder, FontID(fnt1))
ButtonGadget(#B_start, 430, 70, 350, 50, "exit")
SetGadgetFont(#B_start, FontID(fnt1))
EditorGadget(#T_filepath, 10, 140, 780, 50, #PB_Editor_ReadOnly | #PB_Editor_WordWrap)
SetGadgetFont(#T_filepath, FontID(fnt2))
Else
window_flg = #False
EndIf
EndProcedure
Procedure SyncPhotoFolders(folders.s)
Protected share_name.s, sync_clock.l
share_name = GetGadgetText(#T_name)
HideGadget(#T_jpgfile, #True) : ResizeGadget(#T_name, 10, 10, 780, 50)
If ExamineDirectory(1, folders, "*.JPG")
While NextDirectoryEntry(1)
If DirectoryEntryType(1) = #PB_DirectoryEntry_File
AddElement(sync())
sync()\name = folders + DirectoryEntryName(1)
EndIf
Wend
EndIf
If ListSize(sync())>0
ForEach sync()
SetGadgetText(#T_name, "Exif sync > "+share_name+RSet(Str(ListIndex(sync())+1), 4, "0"))
If ReadFile(1, sync()\name)
If Lof(1)>8192
ReadData(1, *imageAdress, 8192)
CloseFile(1)
For I=0 To 8192
If PeekB(*imageAdress+I)=$3A
If PeekB(*imageAdress+I+3)=$3A
If PeekB(*imageAdress+I+9)=$3A
If PeekB(*imageAdress+I+12)=$3A
sync_clock = ParseDate("%yyyy:%mm:%dd %hh:%ii:%ss", PeekS(*imageAdress+I-4, 19, #PB_Ascii))
If sync_clock>0
If sync()\date=0
sync()\date = sync_clock
ElseIf sync()\date>sync_clock
sync()\date = sync_clock
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
Next
If sync()\date>0
SetFileDate(sync()\name, #PB_Date_Created, sync()\date)
SetFileDate(sync()\name, #PB_Date_Accessed, sync()\date)
SetFileDate(sync()\name, #PB_Date_Modified, sync()\date)
EndIf
EndIf
EndIf
While WindowEvent() : Delay(1) : Wend
Next
;
SortStructuredList(sync(), #PB_Sort_Ascending, OffsetOf(FileS\date), #PB_Long)
;
ForEach sync()
SetGadgetText(#T_name, "Rename sync > "+share_name+RSet(Str(ListIndex(sync())+1), 4, "0"))
RenameFile(sync()\name, GetPathPart(sync()\name)+"\"+share_name+RSet(Str(ListIndex(sync())+1), 4, "0")+".JPG")
While WindowEvent() : Delay(1) : Wend
Next
EndIf
HideGadget(#T_jpgfile, #False) : ResizeGadget(#T_name, 10, 10, 500, 50)
SetGadgetText(#T_name, share_name)
SetGadgetText(#B_start, "exit")
EndProcedure
Procedure main()
Shared window_flg.b
Protected folders.s, event.l, gadget.l
If window_flg
Repeat
event = WaitWindowEvent() : gadget = EventGadget()
Select event
Case #PB_Event_Gadget
Select gadget
Case #B_folder
folders = PathRequester("please select Sync folders", GetSpecialFolderLocation(39) )
If FileSize(folders) = -2
SetGadgetText(#T_filepath, folders)
SetGadgetText(#B_start, "SYNC")
Else
SetGadgetText(#T_filepath, "")
SetGadgetText(#B_start, "exit")
EndIf
Case #B_start
If GetGadgetText(#B_start)="exit"
Break
EndIf
If FileSize(folders) = -2
SyncPhotoFolders(folders)
EndIf
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
EndIf
EndProcedure
DefaultFontLoad()
OpenWindow_main()
main()
End