no LoadImage JPG if Prog starts from CD

Just starting out? Need help? Post your questions and find answers here.
schic
User
User
Posts: 34
Joined: Fri Sep 12, 2003 10:17 am

no LoadImage JPG if Prog starts from CD

Post by schic »

I have coded a little dia show.
Testing it on Harddisk it works fine,
it also shows jpg´s from CD.

When the dia show is started from CD
the program just quits!..no error.
This occurs not with tif-pictures :?
only with jpg.
The error exactly happens at the LoadImage command.
A messagereqester before LoadImage is reporting,
after LoadImage no more.

Does anybody know waht is going on there?
And does anyone know a solution for that problem?

Thanks and greetings
schic
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

To my knowledge this has been reported in the bug section and there is a an update for the jpeg plugin, what i don't remember is if this update addresses this problem, but there's no reason not to try if it helps..
http://www.purebasic.com/update/
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Post by sec »

hi schic,
LoadImage() run (well) with picture (.jpg) on cd-rom. (updated , Pupil talk)

anyway, try:

Code: Select all

UseJPEGImageDecoder()
If OpenWindow(0,0,0,200,300,#pb_window_screencentered,"test view jpg") 
  If StartDrawing(WindowOutput())
    If LoadImage(0,"F:\image\school.jpg") ; F: Cd-rom
      id=UseImage(0)
      ResizeWindow(ImageWidth(),ImageHeight())
      DrawImage(id,0,0)    
    Else
      MessageRequester("","loadimage() return 0 => error",0)
    EndIf
    StopDrawing()
  EndIf
EndIf

Repeat : Until WaitWindowEvent()=#pb_event_closewindow
schic
User
User
Posts: 34
Joined: Fri Sep 12, 2003 10:17 am

Post by schic »

Thank you for the fast answer.
I tried the update but it did not
change anything.

Another strange behavior:
When I copy the prog from CD to HD
with hardcoded directory (F:\ for my CD)
it works.
Seems like a dll or something else
can not be found from CD??
schic
User
User
Posts: 34
Joined: Fri Sep 12, 2003 10:17 am

Post by schic »

Hi sec,

thank you. I tried your code. But it is about the same
way I did it. And it does not work from CD, the same
like mine.
schic
User
User
Posts: 34
Joined: Fri Sep 12, 2003 10:17 am

Post by schic »

@ sec
[quote]LoadImage() run (well) with picture (.jpg) on cd-rom. [quote]

the problem is not loading jpg´s from CD - this is working.
But starting the program from CD causes a crash.

Maybe I have not explained it well. Excuse my bad english.
:oops: schic
Last edited by schic on Fri Sep 12, 2003 12:19 pm, edited 1 time in total.
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Actually it seems my memory sucks because i can't find a bug report on this :) Maybe you should post this in the bug section....
schic
User
User
Posts: 34
Joined: Fri Sep 12, 2003 10:17 am

Post by schic »

maybe somebody will test it before posting it in the bug section.
Here´s the

Code: Select all

Global screen_x.l
Global screen_y.l

Procedure getFileNames(ActPfad$)
  NewList FileList.s()
  Ergebnis = ExamineDirectory(0, ActPfad$, "*")
  Repeat
    DirFlag = NextDirectoryEntry()
    If DirFlag = 1
      DateiName$ = DirectoryEntryName()
      
      Endung$ = GetExtensionPart(DateiName$) 
      ;MessageRequester("Endung$",Endung$,0)
      If Endung$ = "bmp" Or Endung$ = "jpg" Or Endung$ = "jpeg" Or Endung$ = "tif" Or  Endung$ = "tga" Or  Endung$ = "png"Or Endung$ = "JPG" Or Endung$ = "JPEG" Or Endung$ = "TIF" Or  Endung$ = "TGA" Or  Endung$ = "PNG"  
        DateiName$ = ActPfad$ + DateiName$
        ;MessageRequester("DateiName$",DateiName$,0)
        AddElement(FileList())
        FileList()=DateiName$
      EndIf 
    EndIf 
  Until DirFlag = 0
  ResetList(FileList()) 
EndProcedure
 
Procedure showPict(FileName$)
  If LoadImage(0, FileName$)
    PictW=ImageWidth()
    PictH=ImageHeight() 
    If PictW >  screen_x
      PictH = PictH * screen_x / PictW
      PictW = screen_x
    EndIf 
    If PictH >  screen_y
      PictW = PictW * screen_y / PictH
      PictH = screen_y
    EndIf 
    PictX = (screen_x - PictW) / 2
    PictY = (screen_y - PictH) / 2
    ResizeImage(0, PictW, PictH)
    ClearScreen(0,0,0)
    StartDrawing(ScreenOutput())
    DrawImage(UseImage(0), PictX, PictY) 
    StopDrawing()
    FlipBuffers()
    ProcedureReturn = #true
  Else
    MessageRequester("Fehler!",FileName$ + " konnte nicht geöffnet werden.",0)
    ProcedureReturn = #false
  EndIf
    
EndProcedure

Procedure.s ProgNam() 
  ProgPath$ = Space(250) 
  GetModuleFileName_(0,@ProgPath$,250)
  ProcedureReturn ProgPath$
EndProcedure

Pause.b

UseJPEGImageDecoder()
UseTGAImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()

screen_x = GetSystemMetrics_(#SM_CXSCREEN)
screen_y = GetSystemMetrics_(#SM_CYSCREEN)
Pfad$ = GetPathPart(ProgNam());####################
;Pfad$ = "F:\";#####################################
;F: is my CD-Drive. Same problem as with GetPathPart()
getFileNames(Pfad$)
Ergebnis = InitSprite()
  If OpenScreen(screen_x, screen_y, 32, "Dia Show") 
    InitKeyboard()
    InitMouse()    
    ExamineKeyboard()
    ExamineMouse() 
    While NextElement(FileList()) And KeyboardPushed(#PB_Key_Escape) = 0
        ExamineKeyboard()
        ExamineMouse()
        i=0
        links=0
        rechts=0
        Pause = 0 
        If showPict(FileList())
          Repeat
            ExamineKeyboard()
            ExamineMouse()
            Delay(20)
            If Pause <> 1
              i=i+1
            EndIf 
            If MouseButton(1) Or KeyboardPushed(#PB_Key_Left)
              links = 1
            EndIf 
            If MouseButton(2) Or KeyboardPushed(#PB_Key_Right)
              rechts = 1
            EndIf
            If MouseButton(3) Or KeyboardPushed(#PB_Key_Space)
              Pause = Pause ! 1
            EndIf  
          Until rechts Or links Or KeyboardPushed(#PB_Key_Escape) Or i > 250
          Delay(200)
          FreeImage(0)
        EndIf 
      If links
        PreviousElement(FileList())
        PreviousElement(FileList())
      EndIf
    Wend
    
    CloseScreen()
  EndIf 
  
End
As written - started from HD it shows even jpg´s from CD.
Started from CD it crashes with jpg´s but not with tif´s.

Arrow/mouse right = next pict
ESC = quit
If somebody want´s to do the work an start a burning session ...

PS.: I´m using PureBasic 3.72 on WinXP. The CD is burned with multi session (15 sessions now :( )
Post Reply