Page 1 of 1

Picpak

Posted: Thu Mar 22, 2007 3:21 pm
by Derek
Anyone know where I can get Picpak, can't find it in the search or on google?

Or if it is someone's code can they share it as it would be most useful.

Posted: Thu Mar 22, 2007 4:23 pm
by netmaestro

Code: Select all

;************************************************************** 
; Program:           PicPak 
; Author:            netmaestro 
; Date:              April 15, 2006 
; Target OS:         Microsoft Windows All 
; Target Compiler:   PureBasic 4.xx 
; License:           Free, unrestricted, credit appreciated 
;                    but not required 
;************************************************************** 

Declare CreateDataSection(picin.s) 

Procedure.s GetDroppedFile() 
  buf.s=Space(DragQueryFile_(EventwParam(),0,0,0)) 
  DragQueryFile_(EventwParam(), 0, buf, Len(buf)+1) 
  DragFinish_(EventwParam()) 
  ProcedureReturn buf 
EndProcedure 

line$=Chr(10) 
line$+ "          Written in PureBasic by netmaestro, April 2006"+Chr(10)+Chr(10) 
line$+ "          100% free to use, distribute, reverse-engineer,"+Chr(10) 
line$+ "          repackage and say you wrote it, anything you want"+Chr(10) 
line$+ "          to do with it is A-OK with me"+Chr(10) 

use$=""+Chr(10) 
use$ + Space(3) + "1. Drop an image file on the window"+Chr(13)+Chr(10)+Chr(10) 
use$ + Space(3) + "2. Select a label name"+Chr(13)+Chr(10)+Chr(10) 
use$ + Space(3) + "3. Look for Temp.pbi in this folder"+Chr(13)+Chr(10)+Chr(10) 
use$ + Space(3) + "4. The #image img0 will be ready to use!"+Chr(13)+Chr(10)+Chr(10) 

CreateImage(0, 512,512,32) 
StartDrawing(ImageOutput(0)) 
  Box(0,0,512,512,GetSysColor_(#COLOR_BTNFACE)) 
  Circle(256,256,256,#Red) 
  Circle(256,256,200,#White) 
  Circle(256,256,145,#Red) 
  Circle(256,256,80,#White) 
  Circle(256,256,40,#Red) 
StopDrawing() 
ResizeImage(0,120,120) 

OpenWindow(0,0,0,150,170,"PicPak",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 
ImageGadget(0,15,15,0,0,ImageID(0)) 
DisableGadget(0,1) 
DragAcceptFiles_ (WindowID(0), #True) 
StickyWindow(0,#True) 

If CreateMenu(0, WindowID(0)) 
   MenuTitle("Menu") 
   MenuItem( 1, "Usage") 
   MenuItem( 2, "About...") 
EndIf 

source.s = ProgramParameter() 
If source 
  CreateDataSection(source) 
EndIf 

Repeat 
  ev=WaitWindowEvent() 
  Select ev 
    Case #WM_DROPFILES 
      Source.s = GetDroppedFile() 
      ext.s = GetExtensionPart(source) 
      If FindString("BMP JPG TIF PNG", UCase(ext),1) 
        CreateDataSection(source) 
      Else 
        StickyWindow(0,#False) 
        MessageRequester("Problem","File must be:  BMP, JPG, PNG or TIF",#MB_ICONERROR) 
        StickyWindow(0,#True) 
      EndIf 
    Case #PB_Event_Menu 
      Select EventMenu() 
        Case 1 
          StickyWindow(0,#False) 
          MessageRequester("How to use PicPak",use$,$C0) 
          StickyWindow(0,#True) 
        Case 2 
          StickyWindow(0,#False) 
          MessageRequester("About PicPak",line$, $C0) 
          StickyWindow(0,#True) 
      EndSelect 
  EndSelect 
Until ev=#WM_CLOSE 

Procedure CreateDataSection(picin.s) 
  Pattern$ = "BMP (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif" 
  If picin = " " 
    picin.s = OpenFileRequester("Choose an image file", "", pattern$, 0) 
  EndIf 
  ext.s = GetExtensionPart(picin) 
  If ReadFile(0,picin) 
    FileLength = Lof(0) 
    *Source = AllocateMemory(FileLength) 
    *Target = AllocateMemory(FileLength+8) 
    If FileLength And *Source And *Target 
      ReadData(0, *Source, FileLength) 
      CompressedLength = PackMemory(*Source, *Target, FileLength, 9) 
      If CompressedLength 
        DecompressedLength = UnpackMemory(*Target, *Source) 
        If DecompressedLength = FileLength 
          StickyWindow(0,#False) 
          MessageRequester("Info", "Compression succeeded:"+Chr(10)+Chr(10)+"Old size: "+Str(FileLength)+Chr(10)+"New size: "+Str(CompressedLength), #MB_ICONINFORMATION) 
          StickyWindow(0,#True) 
          FreeMemory(*source) 
          *Source = AllocateMemory(compressedLength) 
          CopyMemory(*target,*source,compressedlength)          
        EndIf    
      Else  
        compressedlength=filelength 
        StickyWindow(0,#False) 
        MessageRequester("Info", "Compression not needed", #MB_ICONINFORMATION) 
        StickyWindow(0,#True) 
      EndIf 
      StickyWindow(0,#False) 
      label.s = InputRequester("Label Input","Enter a label For the DataSection: ","PicPak:") 
      If Trim(label)="" 
        label="picpak" 
      EndIf 
      label="  "+label 
      StickyWindow(0,#True) 
      label=RemoveString(label,":") 
      endlabel.s = label+"end:" 
      label+":" 
      If CreateFile(1,GetHomeDirectory()+"temp.pbi") 
        WriteStringN(1,""):clip$=Chr(10) 
        Select ext 
          Case "jpg" 
            WriteStringN(1,"UseJPEGImageDecoder()"):clip$+"UseJPEGImageDecoder()"+Chr(10) 
          Case "png" 
            WriteStringN(1,"UsePNGImageDecoder()"):clip$+"UsePNGImageDecoder()"+Chr(10) 
          Case "tif" 
            WriteStringN(1,"UseTIFFImageDecoder()"):clip$+"UseTIFFImageDecoder()"+Chr(10) 
        EndSelect 
        If compressedlength<>filelength 
          WriteStringN(1,"*unpacked = AllocateMemory("+Str(Filelength)+")") 
          WriteStringN(1,"UnpackMemory(?"+Trim(RemoveString(label,":"))+", *unpacked)") 
          WriteStringN(1,"img0 = CatchImage(#PB_Any, *unpacked, "+Str(Filelength)+")") 
          clip$+"*unpacked = AllocateMemory("+Str(Filelength)+")"+Chr(10) 
          clip$+"UnpackMemory(?"+Trim(RemoveString(label,":"))+", *unpacked)"+Chr(10) 
          clip$+"img0 = CatchImage(#PB_Any, *unpacked, "+Str(Filelength)+")"+Chr(10) 
        Else 
          WriteStringN(1,"img0 = CatchImage(#PB_Any, ?" + Trim(RemoveString(label,":")) + ", "+Str(Filelength)+")") 
          clip$+"img0 = CatchImage(#PB_Any, ?" + Trim(RemoveString(label,":")) + ", "+Str(Filelength)+")"+Chr(10) 
        EndIf 
        clip$+Chr(10) 
        SetClipboardText(clip$) 
        WriteStringN(1,"") 
        WriteStringN(1,"Datasection") 
        WriteStringN(1,label) 
        WriteString(1,"  Data.b ") 
        c=0 
        For i = 0 To compressedlength-1 
          If i=compressedlength-1 
            lastbyte=#True 
          Else 
            lastbyte=#False 
          EndIf 
          c+1 
          If c >= 20 Or lastbyte 
            c = 0 
            WriteStringN(1, "$"+RSet(Hex(PeekC(*source+i)),2,"0")) 
            If Not lastbyte 
              WriteString(1,"  Data.b ") 
            EndIf 
          Else 
            WriteString(1, "$"+RSet(Hex(PeekC(*source+i)),2,"0")+",") 
          EndIf 
        Next 
        WriteStringN(1,endlabel) 
        WriteStringN(1,"EndDatasection") 
        CloseFile(1) 
        FreeMemory(*Source) 
        FreeMemory(*Target) 
        CloseFile(0) 
        MessageRequester("Success!","Temp.pbi successfully created: "+GetHomeDirectory()+"temp.pbi") 
      Else 
        MessageRequester("Problem","Could not open the output file") 
      EndIf 
    Else 
      MessageRequester("Problem","Could not allocate the memory... file too large?") 
    EndIf 
  Else 
    MessageRequester("Problem","Could not open input file") 
  EndIf 
EndProcedure 

Posted: Thu Mar 22, 2007 8:14 pm
by netmaestro
oops I forgot I had manually turned compressing off in that code, so if you tried it before now it probably didn't compress anything. I turned it back on now.

Posted: Thu Mar 22, 2007 10:31 pm
by Derek
Just got in from work, will give it a try tomorrow.

Thanks very much, netmaestro. :)

Re: Picpak

Posted: Sun Feb 10, 2013 7:15 am
by yrreti
netmaestro

That picpak program you wrote has been very useful to a lot on this forum as search results show.
But with PB version 5.10, they took away the UnpackMemory command, so it no longer works.
http://www.purebasic.fr/english/viewtop ... packMemory
The so called new method looks a lot more complex to me, and I just don't understand it.
It now looks like that in order to advance to PB5.10, I will have to completely redue every piece of code
where I used it.
Is there any possibility that you could add the necessary changes to get it working again?
I'm sure all of us would really appreciate it.

Re: Picpak

Posted: Sun Feb 10, 2013 7:31 am
by netmaestro
working...
working...
done.

Code: Select all

;**************************************************************
; Program:           PicPak
; Author:            netmaestro
; Date:              April 15, 2006
; Updated:           February 9, 2013
; Target OS:         Microsoft Windows All
; Target Compiler:   PureBasic 5.10 and later
; License:           Free, unrestricted, credit appreciated
;                    but not required
;**************************************************************

UseZipPacker()

Declare CreateDataSection(picin.s)

Global clip$

Procedure.s GetDroppedFile()
  buf.s=Space(DragQueryFile_(EventwParam(),0,0,0))
  DragQueryFile_(EventwParam(), 0, buf, Len(buf)+1)
  DragFinish_(EventwParam())
  ProcedureReturn buf
EndProcedure

line$=Chr(10)
line$+ "          Written in PureBasic by netmaestro, April 2006"+Chr(10)+Chr(10)
line$+ "          Updated February 2013 to generate quads with PB 5.10 Line continuations"+Chr(10)+Chr(10)
line$+ "          100% free to use, distribute, reverse-engineer,"+Chr(10)
line$+ "          repackage and say you wrote it, anything you want"+Chr(10)
line$+ "          to do with it is A-OK with me"+Chr(10)

use$=""+Chr(10)
use$ + Space(3) + "1. Drop an image file on the window"+Chr(13)+Chr(10)+Chr(10)
use$ + Space(3) + "2. Select a label name"+Chr(13)+Chr(10)+Chr(10)
use$ + Space(3) + "3. Paste generated code into your source"+Chr(13)+Chr(10)+Chr(10)
use$ + Space(3) + "4. The #image img0 will be ready to use!"+Chr(13)+Chr(10)+Chr(10)

CreateImage(0, 512,512,32)
StartDrawing(ImageOutput(0))
  Box(0,0,512,512,GetSysColor_(#COLOR_BTNFACE))
  Circle(256,256,256,#Red)
  Circle(256,256,200,#White)
  Circle(256,256,145,#Red)
  Circle(256,256,80,#White)
  Circle(256,256,40,#Red)
StopDrawing()
ResizeImage(0,120,120)

OpenWindow(0,0,0,150,170,"PicPak",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGadget(0,15,15,0,0,ImageID(0))
DisableGadget(0,1)
DragAcceptFiles_ (WindowID(0), #True)
StickyWindow(0,#True)

If CreateMenu(0, WindowID(0))
  MenuTitle("Menu")
  MenuItem( 1, "Usage")
  MenuItem( 2, "About...")
EndIf

source.s = ProgramParameter()
If source
  CreateDataSection(source)
EndIf

Repeat
  ev=WaitWindowEvent()
  Select ev
    Case #WM_DROPFILES
      Source.s = GetDroppedFile()
      ext.s = GetExtensionPart(source)
      If FindString("BMP JPG TIF PNG", UCase(ext),1)
        CreateDataSection(source)
      Else
        StickyWindow(0,#False)
        MessageRequester("Problem","File must be:  BMP, JPG, PNG or TIF",#MB_ICONERROR)
        StickyWindow(0,#True)
      EndIf
    Case #PB_Event_Menu
      Select EventMenu()
        Case 1
          StickyWindow(0,#False)
          MessageRequester("How to use PicPak",use$,$C0)
          StickyWindow(0,#True)
        Case 2
          StickyWindow(0,#False)
          MessageRequester("About PicPak",line$, $C0)
          StickyWindow(0,#True)
      EndSelect
  EndSelect
Until ev=#WM_CLOSE

Procedure CreateDataSection(picin.s)
  Pattern$ = "BMP (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif"
  If picin = " "
    picin.s = OpenFileRequester("Choose an image file", "", pattern$, 0)
  EndIf
  ext.s = GetExtensionPart(picin)
  If ReadFile(0,picin)
    FileLength = Lof(0)
    *original = AllocateMemory(FileLength)
    *compressed = AllocateMemory(FileLength)
    If FileLength And *original And *compressed
      ReadData(0, *original, FileLength)
      CompressedLength = CompressMemory(*original, MemorySize(*original), *compressed, FileLength)
      If CompressedLength>0 And CompressedLength<FileLength
        *compressed = ReAllocateMemory(*compressed, CompressedLength)
        DecompressedLength = UncompressMemory(*compressed, MemorySize(*compressed), *original, MemorySize(*original))
        If DecompressedLength = FileLength
          StickyWindow(0,#False)
          MessageRequester("Info", "Compression succeeded:"+Chr(10)+Chr(10)+"Old size: "+Str(FileLength)+Chr(10)+"New size: "+Str(CompressedLength), #MB_ICONINFORMATION)
          StickyWindow(0,#True)
          FreeMemory(*original)
          *original = AllocateMemory(compressedLength)
          CopyMemory(*compressed,*original,compressedlength)         
        EndIf   
      Else 
        compressedlength=filelength
        StickyWindow(0,#False)
        MessageRequester("Info", "Compression not needed", #MB_ICONINFORMATION)
        StickyWindow(0,#True)
      EndIf
      StickyWindow(0,#False)
      label.s = InputRequester("Label Input","Enter a label For the DataSection: ","PicPak:")
      If Trim(label)=""
        label="picpak"
      EndIf
      label="  "+label
      StickyWindow(0,#True)
      label=RemoveString(label,":")
      endlabel.s = label+"end:"
      label+":"
      clip$=Chr(10)
      Select ext
        Case "jpg"
          clip$+"UseJPEGImageDecoder()"+Chr(10)
        Case "png"
          clip$+"UsePNGImageDecoder()"+Chr(10)
        Case "tif"
          clip$+"UseTIFFImageDecoder()"+Chr(10)
      EndSelect
      If compressedlength<>filelength
        clip$+"UseZipPacker()"+Chr(10)
        clip$+"*unpacked = AllocateMemory("+Str(Filelength)+")"+Chr(10)
        clip$+"Uncompressmemory(?"+Trim(RemoveString(label,":"))+", "+CompressedLength+", *unpacked, "+FileLength+")"+Chr(10)
        clip$+"img0 = CatchImage(#PB_Any, *unpacked, "+Str(Filelength)+")"+Chr(10)
      Else
        clip$+"img0 = CatchImage(#PB_Any, ?" + Trim(RemoveString(label,":")) + ", "+Str(Filelength)+")"+Chr(10)
      EndIf
      clip$+Chr(10)
      clip$ + "Datasection" + Chr(10)
      clip$ + label + Chr(10)
      clip$ + "  Data.q " 
      quads = CompressedLength/8
      bytes = compressedlength%8
 
      For i = 0 To quads-1 
        clip$ + "$"+RSet(Hex(PeekQ(*original+(i*8)),#PB_Quad),16,"0")+","
        If (i+1)%6=0
          If i<>quads-1
            clip$ + Chr(10)+Space(9)
          EndIf
        EndIf
      Next
      clip$=Left(clip$, Len(clip$)-1)+Chr(10)
      If bytes
        *bytestart = *original+(quads*8)
        clip$ + Space(2) + "Data.b "
        For i=0 To bytes-1
          clip$ + "$"+RSet(Hex(PeekA(*bytestart+i),#PB_Ascii),2,"0")+","
        Next
        clip$=Left(clip$, Len(clip$)-1)+Chr(10)
      EndIf 
      clip$ + endlabel + Chr(10)
      clip$ + "EndDatasection" + Chr(10)
      SetClipboardText(clip$)
      FreeMemory(*original)
      FreeMemory(*compressed)
      CloseFile(0)
      MessageRequester("Success!","Datasection is on the clipboard")
    EndIf
  Else
    MessageRequester("Problem","Could not open input file")
  EndIf
EndProcedure
It generates quads now for a smaller datasection and output goes to the clipboard.

Re: Picpak

Posted: Sun Feb 10, 2013 2:07 pm
by yrreti
netmaestro

Thank you so 'very' much for updating this!
It's a great little program, and I'm sure a lot of others will appreciate this too.

Thank you Sincerely
yrreti

P.S. I like the change in sending it to the ClipBoard instead of a file too. Nice 8)

Re: Picpak

Posted: Mon Feb 11, 2013 1:21 am
by WilliamL
If I take out the drag&Drop code (not working on the Mac right now) and use file requesters and edit the message requesters will this code be cross-platform or is there more involved?

Re: Picpak

Posted: Mon Feb 11, 2013 1:34 am
by netmaestro
I'm not clear on why the message requesters would need an edit, but basically what you propose should do it. The code was originally written before we had native drag&drop, maybe I'll update that part too.

Re: Picpak

Posted: Mon Feb 11, 2013 1:43 am
by WilliamL
Great I'll see what I can do.

Code: Select all

MessageRequester("Problem","File must be:  BMP, JPG, PNG or TIF",#MB_ICONERROR)
The IDE complained about the #MB_ICONERROR. I also added the color constants (not on the Mac). I've just commented out the drag/drop so there may be some surprises yet otherwise it is running. The Requester file patterns don't work on the Mac either (no big deal).

This version runs on my Mac.

Code: Select all

;**************************************************************
; Program:           PicPak
; Author:            netmaestro
; Date:              April 15, 2006
; Updated:           February 9, 2013
; Target OS:         Microsoft Windows All
; Target Compiler:   PureBasic 5.10 and later
; License:           Free, unrestricted, credit appreciated
;                    but not required
;**************************************************************
; *** Mac version ***
UseZipPacker()
#Red=$0000FF
#White=$FFFFFF

Global clip$

line$=Chr(10)
line$+ "Written in PureBasic by netmaestro, April 2006"+Chr(10)+Chr(10)
line$+ "Updated February 2013 to generate quads with PB 5.10 Line continuations"+Chr(10)+Chr(10)
line$+ "100% free to use, distribute, reverse-engineer,"+Chr(10)
line$+ "repackage and say you wrote it, anything you want"+Chr(10)
line$+ "to do with it is A-OK with me"+Chr(10)

use$=""+Chr(10)
use$ + Space(3) + "1. Drop an image file on the window"+Chr(13)+Chr(10)+Chr(10)
use$ + Space(3) + "2. Select a label name"+Chr(13)+Chr(10)+Chr(10)
use$ + Space(3) + "3. Paste generated code into your source"+Chr(13)+Chr(10)+Chr(10)
use$ + Space(3) + "4. The #image img0 will be ready to use!"+Chr(13)+Chr(10)+Chr(10)

Procedure CreateDataSection(picin.s)
  Pattern$ = "BMP (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif"
  If picin = ""
    picin.s = OpenFileRequester("Choose an image file", "", pattern$, 0)
  EndIf
  ext.s = GetExtensionPart(picin)
  If ReadFile(0,picin)
    FileLength = Lof(0)
    *original = AllocateMemory(FileLength)
    *compressed = AllocateMemory(FileLength)
    If FileLength And *original And *compressed
      ReadData(0, *original, FileLength)
      CompressedLength = CompressMemory(*original, MemorySize(*original), *compressed, FileLength)
      If CompressedLength>0 And CompressedLength<FileLength
        *compressed = ReAllocateMemory(*compressed, CompressedLength)
        DecompressedLength = UncompressMemory(*compressed, MemorySize(*compressed), *original, MemorySize(*original))
        If DecompressedLength = FileLength
          StickyWindow(0,#False)
          MessageRequester("Info", "Compression succeeded:"+Chr(10)+Chr(10)+"Old size: "+Str(FileLength)+Chr(10)+"New size: "+Str(CompressedLength))
          StickyWindow(0,#True)
          FreeMemory(*original)
          *original = AllocateMemory(compressedLength)
          CopyMemory(*compressed,*original,compressedlength)         
        EndIf   
      Else 
        compressedlength=filelength
        StickyWindow(0,#False)
        MessageRequester("Info", "Compression not needed")
        StickyWindow(0,#True)
      EndIf
      StickyWindow(0,#False)
      label.s = InputRequester("Label Input","Enter a label For the DataSection: ","PicPak:")
      If Trim(label)=""
        label="picpak"
      EndIf
      label="  "+label
      StickyWindow(0,#True)
      label=RemoveString(label,":")
      endlabel.s = label+"end:"
      label+":"
      clip$=Chr(10)
      Select ext
        Case "jpg"
          clip$+"UseJPEGImageDecoder()"+Chr(10)
        Case "png"
          clip$+"UsePNGImageDecoder()"+Chr(10)
        Case "tif"
          clip$+"UseTIFFImageDecoder()"+Chr(10)
      EndSelect
      If compressedlength<>filelength
        clip$+"UseZipPacker()"+Chr(10)
        clip$+"*unpacked = AllocateMemory("+Str(Filelength)+")"+Chr(10)
        clip$+"Uncompressmemory(?"+Trim(RemoveString(label,":"))+", "+CompressedLength+", *unpacked, "+FileLength+")"+Chr(10)
        clip$+"img0 = CatchImage(#PB_Any, *unpacked, "+Str(Filelength)+")"+Chr(10)
      Else
        clip$+"img0 = CatchImage(#PB_Any, ?" + Trim(RemoveString(label,":")) + ", "+Str(Filelength)+")"+Chr(10)
      EndIf
      clip$+Chr(10)
      clip$ + "Datasection" + Chr(10)
      clip$ + label + Chr(10)
      clip$ + "  Data.q " 
      quads = CompressedLength/8
      bytes = compressedlength%8
 
      For i = 0 To quads-1 
        clip$ + "$"+RSet(Hex(PeekQ(*original+(i*8)),#PB_Quad),16,"0")+","
        If (i+1)%6=0
          If i<>quads-1
            clip$ + Chr(10)+Space(9)
          EndIf
        EndIf
      Next
      clip$=Left(clip$, Len(clip$)-1)+Chr(10)
      If bytes
        *bytestart = *original+(quads*8)
        clip$ + Space(2) + "Data.b "
        For i=0 To bytes-1
          clip$ + "$"+RSet(Hex(PeekA(*bytestart+i),#PB_Ascii),2,"0")+","
        Next
        clip$=Left(clip$, Len(clip$)-1)+Chr(10)
      EndIf 
      clip$ + endlabel + Chr(10)
      clip$ + "EndDatasection" + Chr(10)
      SetClipboardText(clip$)
      FreeMemory(*original)
      FreeMemory(*compressed)
      CloseFile(0)
      MessageRequester("Success!","Datasection is on the clipboard")
    EndIf
  Else
    MessageRequester("Problem","Could not open input file")
  EndIf
EndProcedure

CreateImage(0, 512,512,32)
StartDrawing(ImageOutput(0))
  Box(0,0,512,512,#White)
  Circle(256,256,256,#Red)
  Circle(256,256,200,#White)
  Circle(256,256,145,#Red)
  Circle(256,256,80,#White)
  Circle(256,256,40,#Red)
StopDrawing()
ResizeImage(0,120,120)

OpenWindow(0,0,0,150,170,"PicPak",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGadget(0,15,15,0,0,ImageID(0))
DisableGadget(0,1)
StickyWindow(0,#True)

If CreateMenu(0, WindowID(0))
  MenuTitle("Menu")
  MenuItem( 1, "Usage")
  MenuItem( 2, "About...")
  MenuBar()
  MenuItem(3,"Load pict")
EndIf

source.s=OpenFileRequester("Choose an image file", "", "BMP (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif",0)
  If Len(source) : CreateDataSection(source) : EndIf

Repeat
  ev=WaitWindowEvent()
  Select ev
    Case #PB_Event_Menu
      Select EventMenu()
        Case 1
          StickyWindow(0,#False)
          MessageRequester("How to use PicPak",use$,$C0)
          StickyWindow(0,#True)
        Case 2
          StickyWindow(0,#False)
          MessageRequester("About PicPak",line$, $C0)
          StickyWindow(0,#True)
        Case 3 ; load
          source.s=OpenFileRequester("Load picture...","Test.jpg","BMP (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif",0)
          If Len(source) : CreateDataSection(source) : EndIf
      EndSelect
  EndSelect
Until ev=#PB_Event_CloseWindow