Image decoders fail in DLL

Everything else that doesn't fall into one of the other PB categories.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Image decoders fail in DLL

Post 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()
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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.
Max.²
Enthusiast
Enthusiast
Posts: 175
Joined: Wed Jul 28, 2004 8:38 am

Post 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?
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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()
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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.
Max.²
Enthusiast
Enthusiast
Posts: 175
Joined: Wed Jul 28, 2004 8:38 am

Post 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.
Max.²
Enthusiast
Enthusiast
Posts: 175
Joined: Wed Jul 28, 2004 8:38 am

Post 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?
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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.
Max.²
Enthusiast
Enthusiast
Posts: 175
Joined: Wed Jul 28, 2004 8:38 am

Post 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?
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

(deleted by myself), I'm going to post my issue in a different thread ...
Post Reply