airsoftsoftwair wrote:Hmm, sounds weird. Can you upload a complete demo script (with a sample image) that I can just run and try here?
Here's a short working demo program (a very basic thumbnail viewer) showing this behaviour:
Code: Select all
@DISPLAY {Width = 880, Height = 600, Color = #WHITE}
kx=0
mytemppath$="ram:" ; does work only with _less_ than 10 pictures with an embedded thumbnail
;mytemppath$="work:pixx/" ; does always work, adjust your path
Function p_mythumb()
OpenFile (1,fullpath$)
jpgstringsize$=30000
If FileSize(fullpath$)<30000 Then jpgstringsize$= FileSize(fullpath$)
my_rawjpg$=ReadString(1,jpgstringsize$)
thumbstart$=(PatternFindStrDirect(my_rawjpg$,"\255\216",100))
thumbend$=(PatternFindStrDirect(my_rawjpg$,"\255\217",100))
If thumbend$ <> -1 And thumbend$>thumbstart$
my_thumb = DefineVirtualFile(fullpath$, thumbstart$, thumbend$-thumbstart$, "thumbnail.jpg")
DebugPrint ("virtual file defined") ;bis hier alles okay
ret_valx, table=IsPicture(my_thumb) ; <--- here the crash does happen at the 10th repetition if original files are from RAM:
DebugPrint("passed IsPicture for the ", kx,"th time")
If ret_valx=True
DebugPrint(fullpath$)
If ret_valx=True
LoadBrush (kx,my_thumb)
Else
LoadBrush (kx,FullPath$)
EndIf
ScaleBrush (kx, 80, #KEEPASPRAT, smooth)
Else
ret_val, table=IsPicture(fullpath$)
If ret_val=True
LoadBrush (kx,fullpath$)
ScaleBrush (kx, 80, #KEEPASPRAT, smooth)
Else
Local nogood$="No valid thumbnail for file "..fullpath$
DebugPrint(nogood$)
EndIf
EndIf
Else
DebugPrint("No thumb")
ret_val, table=IsPicture(fullpath$)
If ret_val=True
LoadBrush (kx,fullpath$)
ScaleBrush (kx, 80, #KEEPASPRAT, smooth)
Else
Local nogood$="No valid thumbnail for file "..new_file_name$
DebugPrint(nogood$)
EndIf
EndIf
EndFunction
Function get_thumbs()
OpenDirectory (1,mytemppath$)
kx=0
e = NextDirectoryEntry(1)
While e <> Nil
ret_val=False
fullpath$=mytemppath$..e.name
ret_val, table=IsPicture(fullpath$)
If ret_val=True
kx=kx+1
p_mythumb()
If kx>0 Then DisplayBrush(kx, (kx%10)*90-80,10+((kx-kx%10)*7))
EndIf
e = NextDirectoryEntry(1)
Wend
DebugPrint("kx total=",kx)
CloseDirectory(1)
EndFunction
get_thumbs()
Repeat
WaitEvent
Forever
Just adjust the mytemppath$ variable at the scipt's start to a location with some picture files. To trigger a failure just copy at least 10 jpgs (with an embedded thumbnail) to RAM: and run the script. It always crashes (application is mediating) at the isPicture check on virtualfile (thumbnail) #10 on my system.
I didn't include example picture files as it crashes with all picture files I threw at the scipt where a thumbnail was recognized.
If it helps I can send you a MorphOS debug log.