Verfasst: 22.05.2009 19:50
Kann ich nicht bestätigen, ich hab jetzt 300 Bilder hintereinander durchgezackert (alles jpgs allerding).
Code: Alles auswählen
; Plugininterface JA!COMMANDER
; ListLoad is the same as for a TotalCommander ListerPlugin.
; ShowFlags is not supported (ignored in the moment)
Prototype.i ListLoad(ParentWin.i, FileToLoad.p-ascii, ShowFlags.l = 0)
; this is the same as above but not compatible to TotalCommander
; this functions is for Unicode DLLs
Prototype.i ListLoadW(ParentWin.i, FileToLoad.p-unicode, ShowFlags.l = 0)
; This is your cleanup function, the same as in TotalCommander
; This function is not required.
; If TC Or JA!COMMANDER doesn't found this function,
; the window becomes destroyed with DestroyWindow_(hWnd)
Prototype ListCloseWindow(ListWin.i)
EnableExplicit
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
Global win, img, info, con
Enumeration
#Image_Original
#Image_Copied
EndEnumeration
Procedure.s ByteRechner(dSize.d)
Protected Namen = $4B4D4754, i = 24, C.c, Result.s = "0"
If dSize > 0.0
While dSize > 1024 And i >= 0
dSize / 1024
C = (Namen >> i) & $FF
i - 8
Wend
Result = StrD(dSize, 2) + " " + Chr(C) + "Byte"
EndIf
ProcedureReturn Result
EndProcedure
Procedure ResizeMyImage()
Protected x, y, xf.f, yf.f
If IsImage(#Image_Original)
xf = ImageWidth(#Image_Original) / ImageHeight(#Image_Original)
yf = GadgetWidth(con) / (GadgetHeight(con) - 100)
CopyImage(#Image_Original, #Image_Copied)
If xf > yf
xf = GadgetWidth(con) / ImageWidth(#Image_Copied)
If xf > 2
xf = 2
EndIf
ResizeImage(#Image_Copied, ImageWidth(#Image_Copied) * xf, ImageHeight(#Image_Copied) * xf)
ElseIf xf < yf
xf = (GadgetHeight(con) - 100) / ImageHeight(#Image_Copied)
If xf > 2
xf = 2
EndIf
ResizeImage(#Image_Copied, ImageWidth(#Image_Copied) * xf, ImageHeight(#Image_Copied) * xf)
EndIf
SetGadgetState(img, ImageID(#Image_Copied))
EndIf
EndProcedure
Procedure Win_CB(hWnd, uMsg, wParam, lParam)
Protected File.s, pic, Result = #PB_ProcessPureBasicEvents
Protected Pattern.s = "JPEG-Files (*.jpg, *.jpeg)|*.jpg;*.jpeg"
Select uMsg
Case #WM_SIZE
ResizeGadget(img, #PB_Ignore, #PB_Ignore, GadgetWidth(con), GadgetHeight(con) - 100)
ResizeGadget(info, #PB_Ignore, GadgetHeight(con) - 99, GadgetWidth(con), #PB_Ignore)
ResizeMyImage()
Case #WM_COMMAND
If wParam & $FFFF
;Select GetDlgCtrlID_(lParam)
; Case btn
; File = OpenFileRequester("", path, Pattern, 0)
; If File
; pic = LoadImage(#PB_Any, File)
; ResizeImage(pic, GadgetWidth(img), GadgetHeight(img))
; SetGadgetState(img, ImageID(pic))
; EndIf
;EndSelect
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
ProcedureDLL ListLoadW(ParentWin, File.s, Flags)
Protected Result
If Not win
win = OpenWindow(#PB_Any, 0, 0, 322, 150, "PluginDemo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible)
con = ContainerGadget(#PB_Any, 0, 0, WindowWidth(win), WindowHeight(win), #PB_Container_BorderLess)
img = ImageGadget(#PB_Any, 0, 0, 0, 0, 0)
info = EditorGadget(#PB_Any, 0, 0, 320, 98, #PB_Editor_ReadOnly)
Else
HideGadget(con, 0)
EndIf
If LoadImage(#Image_Original, File)
ResizeMyImage()
ClearGadgetItems(info)
AddGadgetItem(info, -1, "Name:" + #TAB$ + #TAB$ + GetFilePart(File))
AddGadgetItem(info, -1, "Path:" + #TAB$ + #TAB$ + GetPathPart(File))
AddGadgetItem(info, -1, "Dimension:" + #TAB$ + Str(ImageWidth(#Image_Original)) + " x " + Str(ImageHeight(#Image_Original)) + " pixel")
AddGadgetItem(info, -1, "Depth:" + #TAB$ + #TAB$ + Str(ImageDepth(#Image_Original)) + " bit")
AddGadgetItem(info, -1, "Size:" + #TAB$ + #TAB$ + ByteRechner(FileSize(File)))
Else
SetGadgetState(img, 0)
SetGadgetText(info, "unknown format")
EndIf
CloseGadgetList()
SetWindowCallback(@Win_CB())
If ParentWin
SetParent_(GadgetID(con), ParentWin)
Result = GadgetID(con)
Else
; only for testing
HideWindow(win, #False)
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL ListCloseWindow(ListWin)
If IsGadget(con)
HideGadget(con, 1)
EndIf
EndProcedure
ProcedureDLL DetachProcess(Instance)
If IsImage(#Image_Original)
FreeImage(#Image_Original)
EndIf
If IsImage(#Image_Copied)
FreeImage(#Image_Copied)
EndIf
FreeGadget(con)
CloseWindow(win)
EndProcedure
Welche fileinfo? Wird das Plugin dann automatisch eingebunden?txt hat geschrieben: ; move it over the fileinfo to work!
Wenn Du das dllview plugin hinter dem fileinfo-plugin einordnest wird dieHeX0R hat geschrieben:Ich verstehe die Aussage in den Text-files der Plugins nicht:txt hat geschrieben: ; move it over the fileinfo to work!
Das ist beim JA!COMMANDER gleich bei, ist nicht im Pluginpack. Ist auchHeX0R hat geschrieben: Welche fileinfo? Wird das Plugin dann automatisch eingebunden?
Eigentlich nicht, weil nicht jeder will sein gif im Browser sehenHeX0R hat geschrieben: Weil irgendwie finde ich das nicht so praktisch, dass ich ein Plugin über den Commander einpflanze, dann aber die möglichen Extensions aus dieser Textdatei mühsam kopieren muss.
Das geht doch bestimmt einfacher?
Eine solche Config sollteste in Dein Plugin integrieren und dort irgendwieHeX0R hat geschrieben: Was auch nett wäre, ein [optionales] Config-Menü für die Plugins.
Sobald sie eine bestimmt Funktion beinhalten, stellt der Commander einen zusätzlichen Button zur Verfügung.