Page 1 of 1
Image decoders fail in DLL
Posted: Fri Oct 29, 2004 5:28 am
by halo
I tried a call in the main program, as well within the function call, and the image decoders fail to work when used in a DLL.
Here, even try this. Run it as a regular PB program, then try it as a DLL.
ProcedureDLL ImageTest(a,b,c,d)
UseJPEGImageDecoder()
result=LoadImage(0,"bankwallwindow.jpg")
MessageRequester("",Str(result),0)
EndProcedure
;imagetest()
Posted: Fri Oct 29, 2004 6:41 am
by halo
Can someone please address this. I have to have a program done December 1, and don't want to get slowed down by stupid little things like this, when I still have hard programming to do.
Posted: Fri Oct 29, 2004 7:49 am
by Max.²
Did you try to do the Initialization of the the JPEG library in the
Code: Select all
; This procedure is called once, when the program loads the library
; for the first time. All init stuffs can be done here (but not DirectX init)
;
ProcedureDLL AttachProcess(Instance)
EndProcedure
procedure?
Posted: Fri Oct 29, 2004 5:16 pm
by halo
I tried this code, and it would not load. I am calling this from Blitz, BTW:
ProcedureDLL AttachProcess(Instance)
UseJPEGImageDecoder()
EndProcedure
ProcedureDLL ImageTest(a,b,c,d)
UseJPEGImageDecoder()
result=LoadImage(0,"bankwallwindow.jpg")
MessageRequester("",Str(result),0)
EndProcedure
;imagetest()
Posted: Fri Oct 29, 2004 5:48 pm
by halo
It seems if I just call this one DLL, it works fine, but when I put it in a program that also calls my other PureBasic DLL's, it doesn't load the image. What a ****ing mess.
Posted: Fri Oct 29, 2004 6:04 pm
by Max.²
halo wrote:I tried this code, and it would not load. I am calling this from Blitz, BTW:
ProcedureDLL AttachProcess(Instance)
UseJPEGImageDecoder()
EndProcedure
ProcedureDLL ImageTest(a,b,c,d)
UseJPEGImageDecoder()
result=LoadImage(0,"bankwallwindow.jpg")
MessageRequester("",Str(result),0)
EndProcedure
;imagetest()
Delete the UseJPEGImageDecoder() from the ImageTest procedure. Works fine here.
Posted: Fri Oct 29, 2004 6:05 pm
by Max.²
halo wrote:It seems if I just call this one DLL, it works fine, but when I put it in a program that also calls my other PureBasic DLL's, it doesn't load the image. What a ****ing mess.
Maybe multiple instances, initializing the same stuff?
Posted: Fri Oct 29, 2004 7:04 pm
by halo
I think PB just doesn't work. Calling this empty DLL anywhere in the program causes the JPEG loader to fail:
ProcedureDLL.l CS_InitLightStatisticsWindow(hwnd,icon)
ProcedureReturn 0
EndProcedure
ProcedureDLL.l CS_ShowLightStatisticsWindow()
ProcedureReturn 0
EndProcedure
I ended up loading the images in Blitz, and then copying them pixel-by-pixel. It's a little slower, but it works alright.
Posted: Fri Oct 29, 2004 10:54 pm
by Max.²
halo wrote:I think PB just doesn't work. Calling this empty DLL anywhere in the program causes the JPEG loader to fail:
ProcedureDLL.l CS_InitLightStatisticsWindow(hwnd,icon)
ProcedureReturn 0
EndProcedure
ProcedureDLL.l CS_ShowLightStatisticsWindow()
ProcedureReturn 0
EndProcedure
I tried this, which should reproduce your troubles and it works for me.
DLL1.DLL
Code: Select all
ProcedureDLL AttachProcess(Instance)
UseJPEGImageDecoder()
EndProcedure
ProcedureDLL ImageTest(a,b,c,d)
result=LoadImage(0,"C:\Dokumente und Einstellungen\A\Eigene Dateien\Eigene Bilder\limecat.jpg")
MessageRequester("",Str(result),0)
EndProcedure
DLL2.DLL
Code: Select all
ProcedureDLL.l CS_InitLightStatisticsWindow(hwnd,icon)
ProcedureReturn 0
EndProcedure
ProcedureDLL.l CS_ShowLightStatisticsWindow()
ProcedureReturn 0
EndProcedure
Test code
Code: Select all
If OpenLibrary(0,"E:\Daten\Sourcecodes\Test\dll1.dll")
If OpenLibrary(1,"E:\Daten\Sourcecodes\Test\dll2.dll")
Debug CallFunction(1,"CS_ShowLightStatisticsWindow",a,b)
Debug CallFunction(0, "ImageTest",a,b,c,d)
EndIf
EndIf
2 things that I saw in your samples; no idea if related but maybe worth to mention:
1. You open a "bankwallwindow.jpg". Shouldn't that be "blankwallwindow.jpg"?
2. I am using absolute paths.
Anyway, do these 3 snippets work for you?
Posted: Sat Oct 30, 2004 12:52 am
by halo
The DLL works by itself, but when I call other DLL's, it fails, only with some DLL's, and there is no pattern to which ones work and which don't...some empty DLL's that do nothing will cause it to fail.
I gave up, anyways, and just used the Blitz loaders.
Posted: Sun Mar 27, 2005 7:19 am
by Shannara
(deleted by myself), I'm going to post my issue in a different thread ...