UNABLE TO PACK !?

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Num3.

Here's an interesting problem i came across & discussed a bit with Fred...

Seems that i'm unable to PACK jpg files together!
The pack returns an error, cause it can compact them anymore...

Here's the code:

Declare PackerProgress(SourcePosition, DestinationPosition)



If OpenWindow(0, 100, 200, 300, 40, #PB_Window_SystemMenu, "Packer - Progress Window")

CreateGadgetList(WindowID())
ProgressBarGadget(0, 10, 10, 280, 20, 0, 100)

If CreatePack("c:\test.bulk")
FileName$ = OpenFileRequester("Please select file to pack", "*.jpg", "*.jpg", 0, #PB_Requester_MultiSelection)
If FileName$
Repeat
If OpenFile(0, FileName$)
FileLength = Lof()
CloseFile(0)
EndIf
FileName$ = NextSelectedFileName()


If FileName$
Debug "Adding:" + FileName$

If AddPackFile(filename$, 0):PackerCallback(@PackerProgress()) : EndIf
EndIf
Until FileName$ = ""
EndIf

ClosePack()
EndIf
EndIf
End



Procedure PackerProgress(SourcePosition, DestinationPosition)
Shared FileLength

Result.f = (SourcePosition / FileLength)*100
SetGadgetState(0, Round(Result, 0))

While (WindowEvent()) : Wend ; Process all the window event befor quit

ProcedureReturn 1
EndProcedure



;-END OF CODE


Btw: I know the parto of getting the file size is pretty lamma...
I know i can use the PB command to do this, but I only found it a few days ago.....


--
Kind Regards
Rui Carvalho

Old programmers never die... They branch into a subroutine...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

If a file is allready packed very good (like jpg, zip), Pb is unable to pack them again.
(Maybe because the result would get bigger that the original data)

In this case, you get an error, and then have to do it some otherr way, for example just store
all data in one file without packing then.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Num3.
Originally posted by freak

If a file is allready packed very good (like jpg, zip), Pb is unable to pack them again.
(Maybe because the result would get bigger that the original data)

In this case, you get an error, and then have to do it some otherr way, for example just store
all data in one file without packing then.
That's what i told Fred, but he said he can pack them anyway !!!
This is very strange :)

--
Kind Regards
Rui Carvalho

Old programmers never die... They branch into a subroutine...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Num3

That's what i told Fred, but he said he can pack them anyway !!!
This is very strange :)
Is Fred using the same JPG images as you are? Not all JPG images are as compressed as each other.



--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.51, Ed3.53)
Post Reply