Page 1 of 2

PicPak Packager

Posted: Thu Sep 04, 2008 11:37 am
by Mistrel
Here is my addition to netmaestro's excellent PicPak code for formatting images for DataSections.

One of the advantages is that I store the packed/unpacked sizes and a compression flag in a header so the image can be extracted at runtime without any hard-coded lengths or ?End-?Start.

Use PickPak Packager in your projects and all you need to include is GetImageResource to read the data back.

Code: Select all

Structure LoadResource
	Filename.s
	Progress.l
	Cancel.l
EndStructure

Enumeration
	#Main_Window
	#Progress_Bar
	#Cancel_Button
	#Preview_Button
	#Open_Button
	#Image_Gadget
	#Image
	#Menu
EndEnumeration

Declare LoadImageResource(*LR.LoadResource)
Declare ClosePreview()
Declare ResizePreview()
Declare OpenNewImage(*LR.LoadResource)
Declare MakeImageResource(File.s, *Progress.LONG, *Cancel.LONG)
Declare GetImageResource(ImageID, *Memory)
Declare TextProgressBarCallback(hWnd, Msg, wParam, lParam)
Declare CreateTextProgressBarGadget(GadgetID, x, y, Width, Height, Minimum, Maximum, FirstTextColor=#PB_Ignore, SecondTextColor=#PB_Ignore, BarColor=#PB_Ignore, BackColor=#PB_Ignore)

Usage.s=Chr(10)
Usage.s+"Each byte is read into PicPak to be converted into a formatted hexedecimal datasection"+Chr(10)+Chr(10)
Usage.s+"When the progress bar is complete the data is copied to the clipboard. Simply paste it"+Chr(10)
Usage.s+"into your IDE, change the label is necessary, and you're good to go."+Chr(10)

About.s=Chr(10)
About.s+"Written in PureBasic by Matthew "+Chr(34)+"Mistrel"+Chr(34)+" D'Onofrio, September 2008"+Chr(10)
About.s+"Adapted from original code by netmaestro and gnozal"+Chr(10)+Chr(10)
About.s+"This code is 100% free to use, distribute, or reverse-engineer"+Chr(10)

UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()

Define LR.LoadResource
Define DefaultWindowHeight=74

; Allow an image to be passed as a parameter
If CountProgramParameters()
	LR\Filename=ProgramParameter(0)
EndIf
ThreadID=OpenNewImage(@LR.LoadResource)

Repeat
	If IsWindow(#Main_Window)
		Event=WaitWindowEvent(1)
	Else
		Delay(1)
	EndIf
	If (IsGadget(#Progress_Bar) And Not GetGadgetState(#Progress_Bar)=100)
		SetGadgetState(#Progress_Bar, LR\Progress)
	EndIf
	Select Event
		Case #PB_Event_Menu
			Select EventMenu()
				Case 0
					MessageRequester("How to use PicPak",Usage.s,$C0)
				Case 1
					MessageRequester("About PicPak",About.s,$C0)
			EndSelect
		Case #PB_Event_Gadget
			Select EventGadget()
				Case #Cancel_Button
					If GetGadgetText(#Cancel_Button)="Done"
						End
					Else
						If IsThread(ThreadID)
							LR\Cancel=1
							Repeat: Delay(10)
								WindowEvent() ; Don't lock the main window
							Until Not IsThread(ThreadID)
							LR\Progress=0
							LR\Filename.s=""
							LR\Cancel=0
						EndIf
						SetGadgetText(#Cancel_Button,"Done")
					EndIf
				Case #Preview_Button
					If WindowHeight(#Main_Window)=DefaultWindowHeight+MenuHeight()
						ResizePreview()
					Else
						ClosePreview()
					EndIf
				Case #Open_Button
					If Not LR\Progress=100
						LR\Cancel=1
						Repeat: Delay(10)
							WindowEvent() ; Don't lock the main window
						Until Not IsThread(ThreadID)
						LR\Cancel=0
					EndIf
					LR\Progress=0
					LR\Filename.s=""
					SetGadgetState(#Progress_Bar,0)
					ThreadID=OpenNewImage(@LR.LoadResource)
					Repeat: Delay(10)
						; Add a timeout here
					Until LR\Filename.s Or Not IsThread(ThreadID)
					; Only resize the preview if a new file has been selected
					If LR\Filename.s
						If Not WindowHeight(#Main_Window)=DefaultWindowHeight+MenuHeight()
							ResizePreview()
						EndIf
					EndIf
			EndSelect
		Case #WM_CLOSE
			End
	EndSelect
ForEver

Procedure LoadImageResource(*LR.LoadResource)
	MakeImageResource(*LR\Filename.s, @*LR\Progress, @*LR\Cancel)
EndProcedure

Procedure ClosePreview()
	ResizeWindow(#Main_Window,#PB_Ignore,#PB_Ignore,#PB_Ignore,MenuHeight()+74)
	HideGadget(#Image_Gadget,1)
EndProcedure

Procedure ResizePreview()
	ResizeWindow(#Main_Window,#PB_Ignore,#PB_Ignore,#PB_Ignore,MenuHeight()+74)
	Width=WindowWidth(#Main_Window)-10
	Height=WindowHeight(#Main_Window)+MenuHeight()-117+220
	ImageWidth=ImageWidth(#Image)
	ImageHeight=ImageHeight(#Image)
	NewHeight=(Width*ImageHeight)/ImageWidth
	NewWidth=Width
	If NewHeight>Height
		NewWidth=(Height*ImageWidth)/ImageHeight
		NewHeight=Height
	EndIf
	If Not NewWidth>ImageWidth And Not NewHeight>ImageHeight
		ResizeImage(#Image,NewWidth,NewHeight,#PB_Image_Smooth)
	Else
		NewWidth=ImageWidth
		NewHeight=ImageHeight
	EndIf
	ResizeWindow(#Main_Window,#PB_Ignore,#PB_Ignore,#PB_Ignore,WindowHeight(#Main_Window)+NewHeight+5)
	ResizeGadget(#Image_Gadget,5,WindowHeight(#Main_Window)-MenuHeight()-NewHeight-5,Width,Height)
	SetGadgetState(#Image_Gadget,ImageID(#Image))
	HideGadget(#Image_Gadget,0)
	If NewWidth<WindowWidth(#Main_Window)
		ResizeGadget(#Image_Gadget,(WindowWidth(#Main_Window)-NewWidth)/2,#PB_Ignore,#PB_Ignore,#PB_Ignore)
	EndIf
	HideGadget(#Image_Gadget,0)
EndProcedure

Procedure OpenNewImage(*LR.LoadResource)
	Shared DefaultWindowHeight
	If Not *LR\Filename.s
		Filename.s=OpenFileRequester("Select File","","*.bmp,*.ico,*.jpeg,*.jpg,*.png,*.tga,*.tif,*.tiff|*.bmp;*.ico;*.jpeg;*.jpg;*.png,*.tga;*.tif;*.tiff",0)
		If Not Filename.s And Not IsWindow(#Main_Window)
			End
		EndIf
	Else
		Filename.s=*LR\Filename.s
	EndIf
	Extension.s=LCase(GetExtensionPart(Filename.s))
	Select Extension.s
		Case "bmp","ico","jpeg","jpg","png","tga","tif","tiff"
			*LR\Filename.s=Filename.s
			If Not LoadImage(#Image,Filename.s)
				MessageRequester("Error","Couldn't load the image")
				End
			EndIf
			If Not IsWindow(#Main_Window)
				OpenWindow(#Main_Window,0,0,250,74+MenuHeight(),"PicPak Packager",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
				If CreateGadgetList(WindowID(#Main_Window))
					CreateTextProgressBarGadget(#Progress_Bar,5,5,240,30,0,100)
					ButtonGadget(#Cancel_Button,185,45,60,24,"Cancel")
					ButtonGadget(#Preview_Button,119,45,60,24,"Preview")
					ButtonGadget(#Open_Button,53,45,60,24,"Open")
					ImageGadget(#Image_Gadget,5,WindowHeight(#Main_Window)-MenuHeight()-NewHeight-5,Width,Height,ImageID(#Image))
					HideGadget(#Image_Gadget,1)
					CreateMenu(#Menu,WindowID(#Main_Window))
					MenuTitle("Help")
					MenuItem(0,"Usage")
					MenuItem(1,"About")
				EndIf
			Else
				DisableGadget(#Preview_Button,0)
				SetGadgetText(#Cancel_Button,"Cancel")
			EndIf
			ThreadID=CreateThread(@LoadImageResource(),*LR)
		Default
			If Filename.s
				MessageRequester("Error","Unknown file type "+Chr(34)+Extension.s+Chr(34))
			EndIf
	EndSelect
	ProcedureReturn ThreadID
EndProcedure

Procedure MakeImageResource(File.s, *Progress.LONG, *Cancel.LONG)
	; If the file exists
	FileSize=FileSize(File.s)
	If Not FileSize>0
		MessageRequester("Error","Not a file or size of 0")
		End
	EndIf
	; And the file is accessable
	Mem=AllocateMemory(FileSize)
	FileID=ReadFile(#PB_Any,File.s)
	If Not FileID
		MessageRequester("Error","Couldn't open the file")
		End
	EndIf
	ReadData(FileID,Mem,FileSize)
	CloseFile(FileID)
	CompressedMem=AllocateMemory(FileSize+8)
	CompressedLength=PackMemory(Mem,CompressedMem,FileSize)
	If CompressedLength
		UnpackLength=UnpackMemory(CompressedMem,Mem)
		If Not UnpackLength=FileSize
			MessageRequester("Error","Failed to verify compression")
			End
		EndIf
		FreeMemory(Mem)
		Mem=AllocateMemory(CompressedLength)
		CopyMemory(CompressedMem,Mem,CompressedLength)
		FreeMemory(CompressedMem)
		Compressed=1
	EndIf
	FilePart.s=GetFilePart(File.s)
	For i=1 To Len(FilePart.s)
		Char.s=Mid(FilePart.s,i,1)
		Asc=Asc(Char.s)
		; If character is not alphanumeric
		If Asc<48 Or (Asc>57 And Asc<65) Or (Asc>90 And Asc<97) Or Asc>122
			Char.s="_"
		EndIf
		Label.s+Char.s
	Next i
	MemSize=MemorySize(Mem)
	HeaderSize=9 ; Byte+Long+Long
	Output.s="DataSection"+#CRLF$
	Output.s+Chr(9)+Label.s+": "+#CRLF$
	Output.s+Chr(9)+"Data.b "
	If Compressed
		Output.s+"$01," ; Compressed
		For i=0 To SizeOf(LONG)-1 ; Uncompressed length
			Output.s+"$"+RSet(Hex(PeekC(@FileSize+i)),2,"0")+","
		Next i
		For i=0 To SizeOf(LONG)-1 ; Compressed length
			Output.s+"$"+RSet(Hex(PeekC(@CompressedLength+i)),2,"0")+","
		Next i
	Else
		Output.s+"$00," ; Uncompressed
		For i=0 To SizeOf(LONG)-1 ; Uncompressed length
			Output.s+"$"+RSet(Hex(PeekC(@FileSize+i)),2,"0")+","
		Next i
		Output.s+"$00,$00,$00,$00," ; Compressed length
	EndIf
	Size=MemSize/20
	If (MemSize%20)
		Size+1
	EndIf
	Dim OutputArray.s(Size)
	n=0
	For i=0 To MemSize-1
		If i=MemSize-1
			LastByte=1 ; True
		Else
			LastByte=0 ; False
		EndIf
		If (Not (i+1+HeaderSize)%20 And Not i=0) Or LastByte
			OutputArray(n)+"$"+RSet(Hex(PeekC(Mem+i)),2,"0")+#CRLF$
			n+1
		Else
			OutputArray(n)+"$"+RSet(Hex(PeekC(Mem+i)),2,"0")+","
		EndIf
		PercentComplete=((i+1.0)/(MemSize+Size))*100-1
		If PercentComplete<0
			PercentComplete=0
		EndIf
		*Progress\L=PercentComplete
		If *Cancel\L
			*Progress\L=0
			ClosePreview()
			DisableGadget(#Preview_Button,1)
			ProcedureReturn 0
		EndIf
	Next
	PreviousCompleted=*Progress\L
	FreeMemory(Mem)
	Mem=AllocateMemory(Size*(20+Len(Chr(9)+"Data.b "+#CRLF$))*4+Len(Output.s+"EndDataSection"))
	PokeS(Mem,Output.s)
	For i=0 To PeekL(@OutputArray()-8)-1
		If OutputArray(i)
			If i=0
				CopyMemory(@OutputArray(i),Mem+(Len(PeekS(Mem))),Len(OutputArray(i)))
			Else
				OutputArray(i)=Chr(9)+"Data.b "+OutputArray(i)
				CopyMemory(@OutputArray(i),Mem+(Len(PeekS(Mem))),Len(OutputArray(i)))
			EndIf
		EndIf
		PercentComplete=(((i-2)+1.0)/(MemSize+Size))*100-1
		If PercentComplete<0
			PercentComplete=0
		EndIf
		*Progress\L=PercentComplete+PreviousCompleted
		If *Cancel\L
			*Progress\L=0
			ClosePreview()
			DisableGadget(#Preview_Button,1)
			ProcedureReturn 0
		EndIf
	Next i
	PokeS(Mem+(Len(PeekS(Mem))),"EndDataSection")
	SetClipboardText(PeekS(Mem))
	FreeMemory(Mem)
	*Progress\L=100
	SetGadgetText(#Cancel_Button,"Done")
EndProcedure

Procedure GetImageResource(ImageID, *Memory)
	Protected Byte,Long
	Byte=SizeOf(BYTE)
	Long=SizeOf(LONG)
	HeaderSize=Byte+Long+Long
	If Not *Memory
		ProcedureReturn 0
	EndIf
	If ImageID=#PB_Any
		i=1
		While IsImage(i)
			i+1
		Wend: Delay(1)
		ImageID=i
	EndIf
	
	; Read header
	Compressed=PeekB(*Memory)
	UnpackLength=PeekL(*Memory+Byte)
	PackedLength=PeekL(*Memory+Byte+Long)
	
	If Compressed ; If the resource is compressed
		Unpacked=AllocateMemory(UnpackLength)
		RepackageMemory=AllocateMemory(PackedLength)
		CopyMemory(*Memory+HeaderSize,RepackageMemory,PackedLength)
		UnpackMemory(RepackageMemory,Unpacked)
		If Not CatchImage(ImageID,Unpacked,UnpackLength)
			FreeImageID=0
		EndIf
		FreeMemory(Unpacked)
		FreeMemory(RepackageMemory)
	Else
		If Not CatchImage(ImageID,*Memory+HeaderSize,UnpackLength)
			FreeImageID=0
		EndIf
	EndIf
	ProcedureReturn ImageID
EndProcedure

Procedure TextProgressBarCallback(hWnd, Msg, wParam, lParam)
	Protected OldProc,ImgID,ImgID2,hdcOut,hdcIn,ps.PAINTSTRUCT,GadgetID
	Protected Text.s,BarColor,Progression.d,BackColor,ProgWidth.d,TextColor2
	OldProc=GetProp_(hWnd,"OldProc")
	TextColor=GetProp_(hWnd,"TextColor")
	TextColor2=GetProp_(hWnd,"TextColor2")
	BackColor=GetProp_(hWnd,"BackColor")
	BarColor=GetProp_(hWnd,"BarColor")
	Select Msg
		Case #WM_PAINT
			GadgetID=GetDlgCtrlID_(hWnd)
			Progression=(GetGadgetState(GadgetID)-GetGadgetAttribute(GadgetID,#PB_ProgressBar_Minimum))/(GetGadgetAttribute(GadgetID,#PB_ProgressBar_Maximum)-GetGadgetAttribute(GadgetID,#PB_ProgressBar_Minimum))
			ProgWidth=GadgetWidth(GadgetID)* Progression
			Text=StrD(Progression*100,0)+"%"
			BeginPaint_(hWnd,@ps)
				hdcOut=ps\hdc
				ImgID2=CreateImage(#PB_Any,GadgetWidth(GadgetID),GadgetHeight(GadgetID),#PB_Image_DisplayFormat)
				StartDrawing(ImageOutput(ImgID2))
					DrawingMode(#PB_2DDrawing_Transparent)
					DrawingFont(GetStockObject_(#DEFAULT_GUI_FONT))
					Box(0,0,GadgetWidth(GadgetID),GadgetHeight(GadgetID),BarColor)
					FrontColor(TextColor)
					DrawText(GadgetWidth(GadgetID)/2-0.5*TextWidth(Text),GadgetHeight(GadgetID)/2-0.5*TextHeight(Text),Text)
				StopDrawing()
				ImgID=CreateImage(#PB_Any,GadgetWidth(GadgetID),GadgetHeight(GadgetID),#PB_Image_DisplayFormat)
				hdcIn=StartDrawing(ImageOutput(ImgID))
					DrawingMode(#PB_2DDrawing_Transparent)
					DrawingFont(GetStockObject_(#DEFAULT_GUI_FONT))
					Box(0,0,GadgetWidth(GadgetID),GadgetHeight(GadgetID),BackColor)
					FrontColor(TextColor2)
					DrawText(GadgetWidth(GadgetID)/2-0.5*TextWidth(Text),GadgetHeight(GadgetID)/2-0.5*TextHeight(Text),Text)
					ImgTmpID=GrabImage(ImgID2 ,#PB_Any,0,0,ProgWidth,GadgetHeight(GadgetID))			 
					DrawImage(ImageID(ImgTmpID),0,0)
					BitBlt_(hdcOut,0,0,GadgetWidth(GadgetID),GadgetHeight(GadgetID),hdcIn,0,0,#SRCCOPY)
				StopDrawing()
			EndPaint_(hWnd,ps)
			FreeImage(ImgID)
			FreeImage(ImgID2)
			FreeImage(ImgTmpID)
			ProcedureReturn 0
		Case #WM_NCDESTROY
			RemoveProp_(hWnd,"OldProc")
			RemoveProp_(hWnd,"TextColor")
			RemoveProp_(hWnd,"TextColor2")
			RemoveProp_(hWnd,"BackColor")
			RemoveProp_(hWnd,"BarColor")
	EndSelect
	ProcedureReturn CallWindowProc_(OldProc, hWnd, Msg, wParam, lParam)
EndProcedure

Procedure CreateTextProgressBarGadget(GadgetID, x, y, Width, Height, Minimum, Maximum, FirstTextColor=#PB_Ignore, SecondTextColor=#PB_Ignore, BarColor=#PB_Ignore, BackColor=#PB_Ignore)
	Protected ImgID,ImgID2
	If GadgetID=#PB_Any
		i=1
		While IsGadget(i)
			i+1
		Wend: Delay(1)
		GadgetID=i
	EndIf
	If FirstTextColor=#PB_Ignore
		FirstTextColor=GetSysColor_(#COLOR_WINDOWTEXT)
	EndIf
	If SecondTextColor=#PB_Ignore
		SecondTextColor=GetSysColor_(#COLOR_HIGHLIGHTTEXT)
	EndIf
	If BackColor=#PB_Ignore
		BackColor=GetSysColor_(#COLOR_BTNFACE)
	EndIf
	If BarColor=#PB_Ignore
		BarColor=GetSysColor_(#COLOR_HIGHLIGHT)
	EndIf
	ProgressBarGadget(GadgetID,X,Y,width,Height,Minimum,Maximum)
	SetProp_(GadgetID(GadgetID),"BackColor",BackColor)
	SetProp_(GadgetID(GadgetID),"BarColor",BarColor)
	SetProp_(GadgetID(GadgetID),"TextColor",SecondTextColor)
	SetProp_(GadgetID(GadgetID),"TextColor2",FirstTextColor)
	SetProp_(GadgetID(GadgetID),"OldProc",SetWindowLong_(GadgetID(GadgetID),#GWL_WNDPROC,@TextProgressBarCallback()))
	ProcedureReturn GadgetID
EndProcedure

Posted: Thu Sep 04, 2008 2:49 pm
by Demivec
Need to add this after line#211:

Code: Select all

CloseFile(FileID)
You can't open a file again if it's still open for modification, this will prevent you accessing the same file twice. IMHO you should use OpenFile() if you only need to read data. Both of these points are reflected in the original PicPak code.

Posted: Thu Sep 04, 2008 4:44 pm
by Mistrel
Thank you, this has been corrected corrected. I can't debug much of anything at 5am it would seem. :)

Posted: Sat Sep 06, 2008 5:15 am
by Mistrel
Added an extra check to close the program if no image is selected the first time.

Posted: Sat Sep 06, 2008 5:46 am
by Mistrel
Corrected a bug that caused with GetImageResource() and #PB_Any that caused it to return an ID that was not unique.

Posted: Sat Sep 06, 2008 7:45 am
by Mistrel
Fixed several bugs and memory leaks.

Posted: Mon Sep 08, 2008 11:16 pm
by eddy
remark : enable ThreadSafe option to compile this code 8)

great tool

Posted: Sun Jun 28, 2009 1:55 pm
by yrreti
Note: This a just a test program.
The PicPaktriangle: DataSection section shows using netmaestro's picpak, and it works as coded.

The Triangle_bmp: DataSection shows using Mistrel's picpak packager, but I don't understand how to use it.

I set up ImageGadget(#Image_1, 350, 10, 140, 120, img0, #PB_Image_Border) to display another
image of img0 to show where I'd like to use picpak packager's img1.
eg: ImageGadget(#Image_1, 350, 10, 140, 120, img1, #PB_Image_Border)
Could you please show me how to do this using your picpak packager program.
Thanks for your help.

Code: Select all

;Note: This a just a test program.
;The PicPaktriangle: DataSection section shows using netmaestro's picpak, and it works as coded.
;
;The Triangle_bmp: DataSection shows using Mistrel's picpak packager,but I don't understand how 
;to use it.
;I set up ImageGadget(#Image_1, 350, 10, 140, 120, img0, #PB_Image_Border) to display another
;image of img0 to show where I'd like to use picpak packager's img1.
;eg: ImageGadget(#Image_1, 350, 10, 140, 120, img1, #PB_Image_Border)
;Could you please show me how to do this using your picpak packager program.
;Thanks for your help.
	 
;{- Enumerations / DataSections
Enumeration
  #Window_0
EndEnumeration
;}
;{ Menu bars
Enumeration
EndEnumeration
;}
;{ Menu/Toolbar items
Enumeration
EndEnumeration
;}
;{ Gadgets
Enumeration
  #Image_0 
  #Image_1  
EndEnumeration
;}
;{ Images
Enumeration
  #img0
  #img1
EndEnumeration
;}
;{ Included Images
*unpacked = AllocateMemory(58434)
UnpackMemory(?PicPaktriangle, *unpacked)
Global img0 = CatchImage(#img0, *unpacked, 58434)

Procedure OpenWindow_Window_0()
  
  If OpenWindow(#Window_0, 220, 150, 600, 180, Space(68)+"PicPak Image Test", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    
    ImageGadget(#Image_0, 70, 10, 140, 120, img0, #PB_Image_Border)
    
    ImageGadget(#Image_1, 350, 10, 140, 120, img0, #PB_Image_Border)
    
  EndIf
EndProcedure
;}

;===========================================================================================
;========         MAIM   PROGRAM   LOOP        =============================================
;===========================================================================================

OpenWindow_Window_0()

;{- Event loop
Repeat
  Event = WaitWindowEvent()
  
  Select Event
    
  Case #PB_Event_CloseWindow
    End
    
  Default
    
  EndSelect  
ForEver
  
  ;*unpacked = AllocateMemory(58434)
  ;UnpackMemory(?PicPaktriangle, *unpacked)
  ;img0 = CatchImage(#PB_Any, *unpacked, 58434)
  
  DataSection
    PicPaktriangle:
    Data.b $4A,$43,$42,$E4,$00,$00,$A9,$D8,$5A,$3B,$A4,$A9,$D0,$20,$A6,$51,$84,$FC,$4B,$28
    Data.b $23,$C0,$28,$2D,$96,$18,$31,$C0,$18,$09,$60,$82,$18,$C3,$BA,$09,$38,$15,$57,$53
    Data.b $C4,$EE,$CC,$7F,$4A,$79,$01,$93,$FC,$07,$63,$3A,$FA,$BF,$EA,$53,$8A,$2A,$2B,$35
    Data.b $3E,$AF,$AA,$EA,$53,$CA,$E2,$CB,$81,$2A,$A7,$A8,$EB,$94,$AD,$B2,$FB,$7A,$4E,$29
    Data.b $EB,$64,$43,$A0,$A8,$EE,$3E,$2B,$AF,$B8,$B2,$AB,$2F,$8A,$1D,$28,$4B,$F5,$F2,$02
    Data.b $CC,$BF,$29,$BA,$2A,$94,$53,$CA,$EF,$48,$B3,$14,$8D,$EA,$27,$A5,$3C,$1B,$AF,$98
    Data.b $39,$AE,$5E,$C5,$40,$F3,$29,$C5,$75,$EC,$65,$27,$46,$F5,$CD,$16,$17,$8D,$17,$29
    Data.b $C5,$DF,$51,$47,$50,$54,$44,$1D,$B5,$A5,$17,$B9,$D9,$2D,$42,$51,$24,$46,$91,$52
    Data.b $FC,$6F,$14,$AA,$E2,$75,$7A,$52,$CA,$BA,$8B,$BB,$53,$CA,$49,$29,$6A,$11,$BE,$46
    Data.b $F3,$FF,$BC,$57,$F4,$CE,$17,$8B,$BB,$CB,$52,$8A,$00,$63,$68,$BC,$AC,$2A,$1B,$89
    Data.b $A3,$AF,$B2,$3A,$52,$8A,$88,$A3,$EB,$94,$0A,$D2,$CA,$AF,$3E,$76,$8F,$BB,$BC,$8F
    Data.b $E4,$B3,$A8,$AE,$B0,$E9,$CF,$EB,$68,$BC,$F8,$E8,$2A,$92,$F9,$BC,$EF,$F8,$41,$28
    Data.b $FE,$23,$22,$B6,$8A,$EB,$43,$F3,$8A,$EB,$3A,$4E,$2B,$EB,$FE,$19,$EC,$F2,$B3,$2E
    Data.b $DB,$F2,$CF,$BE,$2E,$FC,$94,$B2,$EE,$8F,$FC,$CA,$BA,$EB,$B6,$8E,$EA,$0C,$94,$E2
    Data.b $EF,$D2,$55,$EA,$A2,$EB,$02,$BD,$F3,$3A,$65,$B8,$AC,$BE,$CE,$89,$BB,$EC,$BA,$0B
    Data.b $FF,$F8,$93,$F7,$2E,$FA,$EB,$4E,$29,$EB,$CF,$D2,$BE,$B8,$AB,$3B,$A5,$E8,$3F,$1D
    Data.b $FF,$F2,$AE,$EE,$94,$F2,$AB,$BD,$A9,$8E,$AB,$BA,$53,$8A,$BB,$16,$E4,$3A,$F8,$BF
    Data.b $4E,$29,$A8,$DB,$84,$EE,$F3,$FE,$3A,$A5,$F2,$6E,$65,$BB,$8E,$FA,$EB,$94,$8B,$BF
    Data.b $DD,$FC,$F8,$EF,$C0,$B8,$AF,$E8,$2A,$C0,$3B,$BA,$2F,$43,$29,$BA,$97,$A4,$A5,$AC
    Data.b $BA,$49,$FB,$F3,$EF,$3A,$94,$B2,$7E,$7F,$FD,$CF,$BA,$EB,$53,$8A,$FE,$45,$AC,$2A
    Data.b $BE,$AE,$53,$CA,$FF,$8D,$B9,$2A,$AF,$AE,$94,$E2,$AA,$D4,$BA,$8A,$AA,$EB,$A5,$EC
    Data.b $2A,$47,$AF,$B2,$BF,$3A,$29,$EA,$4A,$86,$AB,$B8,$AF,$4E,$CA,$BB,$B2,$F6,$2B,$BF
    Data.b $AB,$53,$E2,$AF,$F4,$AC,$BE,$AB,$1F,$BF,$BA,$30,$EC,$2A,$AA,$9B,$94,$B2,$AB,$AB
    Data.b $53,$CA,$BB,$CC,$F8,$2B,$2A,$69,$FB,$F2,$1A,$B8,$2B,$FB,$9B,$94,$E2,$BE,$AA,$53
    Data.b $CA,$AA,$A4,$BC,$2E,$EA,$EA,$94,$A2,$EA,$7B,$BA,$8B,$AB,$3F,$A5,$BC,$3A,$4D,$BE
    Data.b $CB,$FF,$3F,$A5,$F8,$3A,$1F,$EA,$8B,$FE,$3F,$A5,$AC,$3B,$71,$EB,$CB,$FA,$3F,$A5
    Data.b $E8,$3B,$43,$EF,$8B,$EF,$3F,$A5,$FC,$3B,$15,$FB,$CB,$EB,$3F,$A5,$B8,$3E,$67,$FE
    Data.b $8B,$EA,$3F,$A5,$EC,$3E,$39,$AA,$CE,$BE,$3F,$A5,$A8,$3F,$0B,$AE,$8E,$BB,$3F,$A5
    Data.b $BC,$3F,$5D,$AF,$CE,$AF,$3F,$A5,$F8,$3F,$2F,$BB,$8E,$AE,$3E,$A5,$AC,$6A,$67,$F4
    Data.b $AA,$A8,$E9,$AC,$2B,$FF,$FA,$26,$A5,$AC,$CA,$BE,$53,$8A,$29,$FF,$20,$FA,$BA,$AC
    Data.b $EF,$48,$A5,$AC,$BE,$F7,$15,$8D,$EA,$3A,$56,$E2,$EE,$BC,$46,$BB,$8A,$BB,$48,$BA
    Data.b $8A,$AB,$27,$A5,$FC,$AE,$5A,$EF,$CA,$AF,$1E,$FB,$8B,$2B,$EA,$D6,$E8,$2E,$7B,$D9
    Data.b $AF,$B3,$BA,$49,$29,$AA,$F3,$3E,$A5,$AC,$CB,$BF,$4A,$E5,$29,$AF,$2C,$FE,$94,$F2
    Data.b $EB,$49,$7E,$EB,$8B,$FA,$27,$A5,$E8,$AE,$AE,$53,$CA,$FA,$2A,$07,$BB,$8B,$FF,$27
    Data.b $A5,$B8,$2E,$EF,$53,$CA,$A3,$EF,$1C,$EC,$FF,$DB,$D8,$EE,$AE,$BA,$C5,$2E,$EA,$D5
    Data.b $FC,$3E,$AA,$FA,$94,$E2,$EB,$1D,$AC,$3F,$FB,$EF,$94,$B2,$EE,$65,$B9,$3F,$EE,$EF
    Data.b $94,$A2,$EE,$AD,$E8,$3F,$BF,$EF,$94,$F2,$EF,$F5,$ED,$3F,$BA,$EF,$94,$E2,$FA,$3D
    Data.b $FD,$3F,$AB,$EF,$94,$B2,$7E,$21,$AB,$2A,$BF,$3B,$A5,$E8,$DF,$9C,$AB,$8A,$EE,$4E
    Data.b $29,$BF,$57,$A4,$AB,$F2,$BB,$53,$8A,$FB,$5D,$F8,$AA,$A8,$EE,$94,$B2,$FF,$69,$BF
    Data.b $2A,$BB,$4E,$29,$AA,$2A,$B3,$AE,$E2,$EA,$94,$F2,$AA,$B2,$EF,$2A,$FF,$EB,$29,$BE
    Data.b $2A,$0D,$AF,$A2,$BF,$4E,$B2,$AE,$F2,$A5,$2A,$EB,$EB,$94,$FA,$2A,$31,$FE,$E2,$BB
    Data.b $4E,$29,$AF,$32,$A0,$BA,$AF,$EB,$94,$F2,$2B,$55,$AB,$2B,$DA,$B4,$2B,$AE,$D9,$BE
    Data.b $8A,$EB,$52,$CA,$EE,$8A,$4E,$29,$AB,$6E,$E4,$BB,$B2,$AF,$BB,$F2,$BE,$B2,$AE,$AC
    Data.b $2B,$4C,$F8,$AF,$82,$B9,$B2,$EA,$26,$A5,$2B,$BA,$EA,$94,$BA,$2E,$41,$EF,$AA,$7A
    Data.b $B6,$2F,$CB,$D6,$EF,$8A,$6E,$52,$CA,$AF,$FB,$4F,$29,$AB,$CB,$8D,$AA,$CB,$FB,$53
    Data.b $CA,$BE,$92,$E0,$EA,$B2,$F5,$AA,$A2,$FA,$FE,$2B,$AF,$C7,$29,$AF,$2F,$29,$A5,$AC
    Data.b $BA,$49,$BE,$2E,$FF,$3E,$29,$EB,$2F,$7F,$BA,$CB,$BA,$4F,$8A,$FE,$4B,$94,$AA,$E2
    Data.b $AA,$53,$EE,$E2,$6A,$CB,$F2,$FF,$32,$E2,$93,$B2,$FE,$94,$93,$AE,$8A,$0B,$3E,$C0
    Data.b $EC,$9B,$0D,$AB,$2B,$EB,$00,$AE,$8A,$6E,$F2,$79,$29,$7A,$AB,$E3,$A1,$EE,$E2,$B3
    Data.b $AE,$B2,$18,$EF,$2B,$FF,$C6,$AD,$BB,$B8,$E8,$AE,$A8,$EB,$EA,$CB,$EE,$BE,$CA,$BB
    Data.b $CE,$9A,$A2,$8E,$C0,$FB,$8A,$6A,$CB,$AA,$A8,$7B,$46,$EB,$AE,$EC,$3F,$C0,$F6,$F8
    Data.b $A3,$F5,$3E,$52,$8A,$A7,$68,$BD,$2B,$BB,$60,$EC,$2A,$FE,$61,$BB,$2F,$AE,$BD,$2B
    Data.b $BA,$3B,$48,$29,$EA,$68,$AC,$AF,$B8,$FF,$48,$29,$BA,$BB,$F7,$BA,$AC,$FE,$68,$BC
    Data.b $BC,$BB,$F7,$BA,$EC,$FB,$FA,$2F,$AE,$BB,$2E,$AA,$3E,$29,$8B,$AA,$EE,$BD,$AB,$CF
    Data.b $DE,$FE,$F8,$DF,$A3,$CE,$FA,$34,$FD,$BF,$E8,$3F,$A5,$F8,$FB,$7C,$AC,$EA,$7B,$11
    Data.b $EE,$AC,$AA,$2E,$03,$C0,$1B,$7D,$DF,$2D,$FC,$AC,$BA,$49,$5C,$1D,$F5,$C9,$36,$AE
    Data.b $BF,$02,$54,$59,$75,$93,$AF,$8E,$6B,$38,$1B,$F5,$DF,$54,$E9,$AC,$BA,$49,$76,$1D
    Data.b $7D,$D4,$36,$FE,$BF,$50,$D3,$59,$75,$93,$F9,$3A,$BE,$A8,$6D,$74,$D5,$EF,$AC,$B2
    Data.b $EA,$26,$D4,$1D,$55,$17,$36,$EE,$EA,$9E,$D7,$59,$75,$93,$EE,$CE,$BA,$AF,$1B,$D5
    Data.b $F5,$22,$DA,$AC,$BA,$49,$1B,$7F,$C7,$75,$B7,$8E,$EF,$5A,$80,$71,$DD,$C1,$7C,$EB
    Data.b $A8,$2E,$02,$18,$D7,$1D,$D9,$B0,$8B,$EA,$DB,$19,$7F,$47,$1D,$FF,$8E,$AB,$B0,$0A
    Data.b $57,$77,$09,$DF,$7F,$05,$00,$00,$24,$12
    PicPaktriangleend:
  EndDataSection
  
  DataSection
	Triangle_bmp: 
	Data.b $01,$42,$E4,$00,$00,$AA,$04,$00,$00,$4A,$43,$42,$E4,$00,$00,$A9,$D8,$5A,$3B,$A4
	Data.b $A9,$D0,$20,$A6,$51,$84,$FC,$4B,$28,$23,$C0,$28,$2D,$96,$18,$31,$C0,$18,$09,$60
	Data.b $82,$18,$C3,$BA,$09,$38,$15,$57,$53,$C4,$EE,$CC,$7F,$4A,$79,$01,$93,$FC,$07,$63
	Data.b $3A,$FA,$BF,$EA,$53,$8A,$2A,$2B,$35,$3E,$AF,$AA,$EA,$53,$CA,$E2,$CB,$81,$2A,$A7
	Data.b $A8,$EB,$94,$AD,$B2,$FB,$7A,$4E,$29,$EB,$64,$43,$A0,$A8,$EE,$3E,$2B,$AF,$B8,$B2
	Data.b $AB,$2F,$8A,$1D,$28,$4B,$F5,$F2,$02,$CC,$BF,$29,$BA,$2A,$94,$53,$CA,$EF,$48,$B3
	Data.b $14,$8D,$EA,$27,$A5,$3C,$1B,$AF,$98,$39,$AE,$5E,$C5,$40,$F3,$29,$C5,$75,$EC,$65
	Data.b $27,$46,$F5,$CD,$16,$17,$8D,$17,$29,$C5,$DF,$51,$47,$50,$54,$44,$1D,$B5,$A5,$17
	Data.b $B9,$D9,$2D,$42,$51,$24,$46,$91,$52,$FC,$6F,$14,$AA,$E2,$75,$7A,$52,$CA,$BA,$8B
	Data.b $BB,$53,$CA,$49,$29,$6A,$11,$BE,$46,$F3,$FF,$BC,$57,$F4,$CE,$17,$8B,$BB,$CB,$52
	Data.b $8A,$00,$63,$68,$BC,$AC,$2A,$1B,$89,$A3,$AF,$B2,$3A,$52,$8A,$88,$A3,$EB,$94,$0A
	Data.b $D2,$CA,$AF,$3E,$76,$8F,$BB,$BC,$8F,$E4,$B3,$A8,$AE,$B0,$E9,$CF,$EB,$68,$BC,$F8
	Data.b $E8,$2A,$92,$F9,$BC,$EF,$F8,$41,$28,$FE,$23,$22,$B6,$8A,$EB,$43,$F3,$8A,$EB,$3A
	Data.b $4E,$2B,$EB,$FE,$19,$EC,$F2,$B3,$2E,$DB,$F2,$CF,$BE,$2E,$FC,$94,$B2,$EE,$8F,$FC
	Data.b $CA,$BA,$EB,$B6,$8E,$EA,$0C,$94,$E2,$EF,$D2,$55,$EA,$A2,$EB,$02,$BD,$F3,$3A,$65
	Data.b $B8,$AC,$BE,$CE,$89,$BB,$EC,$BA,$0B,$FF,$F8,$93,$F7,$2E,$FA,$EB,$4E,$29,$EB,$CF
	Data.b $D2,$BE,$B8,$AB,$3B,$A5,$E8,$3F,$1D,$FF,$F2,$AE,$EE,$94,$F2,$AB,$BD,$A9,$8E,$AB
	Data.b $BA,$53,$8A,$BB,$16,$E4,$3A,$F8,$BF,$4E,$29,$A8,$DB,$84,$EE,$F3,$FE,$3A,$A5,$F2
	Data.b $6E,$65,$BB,$8E,$FA,$EB,$94,$8B,$BF,$DD,$FC,$F8,$EF,$C0,$B8,$AF,$E8,$2A,$C0,$3B
	Data.b $BA,$2F,$43,$29,$BA,$97,$A4,$A5,$AC,$BA,$49,$FB,$F3,$EF,$3A,$94,$B2,$7E,$7F,$FD
	Data.b $CF,$BA,$EB,$53,$8A,$FE,$45,$AC,$2A,$BE,$AE,$53,$CA,$FF,$8D,$B9,$2A,$AF,$AE,$94
	Data.b $E2,$AA,$D4,$52,$8A,$AA,$EB,$3A,$A5,$E8,$2A,$8A,$94,$A2,$EA,$AF,$4E,$29,$BF,$BB
	Data.b $22,$A5,$EC,$EE,$AB,$53,$8A,$B2,$AF,$48,$29,$CA,$EF,$EA,$94,$A5,$A8,$2E,$52,$94
	Data.b $A2,$BB,$3A,$4E,$29,$AF,$8B,$22,$A5,$AC,$AE,$AA,$53,$8A,$EF,$BE,$48,$29,$FE,$BB
	Data.b $EA,$94,$B2,$E8,$2F,$52,$CA,$A2,$AE,$3A,$A5,$29,$FF,$8B,$94,$A5,$EC,$AA,$4E,$53
	Data.b $8A,$AB,$23,$48,$29,$AE,$AA,$FF,$94,$B2,$EB,$EE,$48,$29,$FF,$FA,$FF,$94,$A2,$F2
	Data.b $EE,$48,$29,$29,$EB,$FF,$94,$94,$E2,$EF,$48,$48,$29,$BE,$FF,$FF,$94,$B2,$FA,$FB
	Data.b $48,$29,$AF,$AA,$FF,$94,$A2,$F2,$FB,$48,$29,$29,$FB,$FE,$94,$94,$E2,$FE,$48,$48
	Data.b $29,$EE,$FE,$FE,$94,$B2,$FF,$AA,$49,$29,$BF,$F3,$FA,$94,$A2,$28,$2F,$0C,$FF,$30
	Data.b $CC,$BF,$E9,$05,$18,$70,$FA,$5D,$1C,$C5,$FF,$4A,$51,$2A,$C6,$93,$52,$D4,$7F,$D7
	Data.b $29,$C5,$F7,$4A,$F1,$24,$E6,$2B,$1A,$77,$75,$75,$4D,$4A,$79,$15,$5D,$A7,$94,$22
	Data.b $D6,$55,$AF,$52,$8A,$2A,$C0,$3A,$A5,$E8,$7A,$AF,$C2,$BC,$AC,$AC,$B3,$A3,$A2,$CA
	Data.b $BF,$26,$A5,$49,$29,$FE,$53,$3E,$A5,$AC,$AB,$BF,$4A,$E5,$F3,$94,$8A,$21,$CD,$80
	Data.b $01,$F7,$6A,$97,$6F,$54,$77,$75,$45,$E3,$65,$76,$55,$A4,$94,$71,$74,$9D,$52,$29
	Data.b $45,$55,$5D,$A7,$14,$57,$15,$3F,$B1,$55,$DE,$F9,$97,$CC,$D9,$17,$FF,$4D,$4A,$94
	Data.b $5D,$DD,$62,$4A,$59,$F5,$A4,$A4,$94,$57,$7D,$7D,$4A,$D1,$F5,$F5,$A4,$14,$55,$FD
	Data.b $77,$4A,$F9,$71,$F7,$A4,$94,$14,$F7,$77,$4A,$4A,$D9,$F7,$A4,$A4,$94,$DF,$77,$77
	Data.b $4A,$51,$FD,$FD,$A4,$14,$DD,$D5,$77,$4A,$79,$F1,$FD,$A4,$94,$14,$7F,$77,$4A,$4A
	Data.b $59,$FF,$A4,$A4,$94,$77,$77,$77,$4A,$D1,$FF,$FF,$A4,$14,$75,$5D,$77,$4A,$F9,$5C
	Data.b $55,$A4,$94,$C5,$D5,$9D,$52,$94,$5D,$15,$29,$4A,$F9,$5F,$A7,$29,$45,$5D,$45,$91
	Data.b $52,$F4,$D7,$75,$4A,$79,$57,$55,$A4,$94,$F5,$77,$9D,$52,$FC,$D5,$15,$29,$C5,$79
	Data.b $5D,$A7,$94,$45,$77,$45,$4A,$52,$54,$D7,$29,$4A,$F9,$5D,$91,$A4,$94,$7D,$75,$9D
	Data.b $52,$DC,$57,$15,$29,$C5,$5D,$55,$A7,$94,$FD,$D5,$45,$4A,$F9,$74,$D5,$29,$45,$79
	Data.b $75,$91,$52,$94,$55,$75,$4A,$52,$7C,$5D,$A4,$A4,$14,$FF,$9F,$9F,$52,$D6,$5D,$5D
	Data.b $A4,$94,$F7,$F5,$9F,$52,$F4,$FE,$5D,$A4,$14,$94,$DD,$9F,$52,$52,$5C,$5F,$A4,$A4
	Data.b $14,$D7,$9F,$9F,$52,$76,$5F,$5F,$A4,$94,$7F,$7D,$9F,$52,$D4,$DE,$5F,$A4,$14,$95
	Data.b $5D,$9D,$52,$14,$57,$5B,$56,$52,$FC,$5F,$A4,$61,$52,$F4,$9F,$45,$DD,$4A,$71,$94
	Data.b $55,$1D,$29,$79,$1F,$DF,$A7,$C5,$4B,$D1,$27,$AF,$00,$03,$CE,$FB,$4E,$29,$FF,$B8
	Data.b $52,$A7,$3F,$48,$29,$8A,$C4,$3B,$A5,$FC,$EA,$FC,$C3,$E3,$EC,$E2,$AE,$23,$A5,$D9
	Data.b $F3,$EB,$94,$AB,$7D,$CF,$0A,$75,$01,$06,$DC,$5E,$15,$7B,$D4,$4A,$71,$53,$7B,$29
	Data.b $65,$D7,$47,$17,$29,$65,$D5,$45,$15,$01,$15,$94,$D7,$1D,$29,$93,$52,$FC,$A7,$0D
	Data.b $79,$59,$57,$FD,$B1,$7B,$D6,$FE,$0D,$79,$F1,$54,$7F,$34,$5E,$14,$FF,$43,$5E,$5E
	Data.b $74,$7F,$A4,$A4,$94,$7F,$43,$1E,$75,$7E,$7F,$47,$4A,$59,$D5,$FF,$29,$65,$D7,$75
	Data.b $1F,$29,$E5,$F3,$2F,$C2,$1D,$AF,$2F,$C0,$80,$8A,$EF,$53,$8A,$3B,$FE,$3E,$52,$01
	Data.b $A7,$3E,$D9,$1D,$7D,$5F,$80,$47,$FF,$87,$6F,$B8,$F5,$C1,$D9,$B8,$FE,$02,$0C,$9C
	Data.b $3E,$38,$FB,$76,$7F,$01,$06,$6E,$1D,$35,$5F,$EA,$BF,$00,$03,$BA,$1A,$CD,$2B,$AB
	Data.b $A2,$E6,$8B,$FF,$05,$18,$70,$55,$D4,$7C,$F1,$AA,$03,$0C,$38,$3F,$4E,$EF,$AC,$AE
	Data.b $4E,$29,$EB,$FA,$6A,$52,$CA,$A5,$A8,$4F,$29,$94,$F2,$AF,$26,$6B,$52,$CA,$EE,$B8
	Data.b $4E,$29,$AE,$B2,$BB,$26,$A5,$49,$29,$FF,$94,$3E,$A5,$A8,$AF,$EF,$6B,$52,$8A,$94
	Data.b $B2,$4E,$29,$53,$8A,$FF,$9A,$AA,$9B,$94,$E2,$56,$E1,$53,$CA,$C2,$F7,$5F,$01,$00
	Data.b $00,$89,$44
EndDataSection

Posted: Sun Jun 28, 2009 3:21 pm
by Mistrel
yretti, have a look at the GetImageResource() function. This will convert the datasection address to an image.

Posted: Sun Jun 28, 2009 7:21 pm
by yrreti
Thanks for your reply, but I'm sorry I'm just dense today.
I did see your reference to using GetImageResource, and I did look
at that procedure in your program. But there isn't any example where it is
called from, or even in a search on this forum.
So in the case with my test program above, what would I use to
represent ImageID, and *Memory in my program. They need to have values
to pass to your procedure.
For example ?: Global img1 = GetImageResource(ImageID,*Memory)
Thanks for any help in understanding how to do this. Because I like the idea
that I could store the packed/unpacked sizes and a compression flag in the
header so the image can be extracted at runtime without any hard-coded lengths
or End-Start as you said. It makes for less code and less confusion, especially
if using multiple images.
Thank you for your help.

Posted: Mon Jun 29, 2009 5:16 am
by Mistrel
You can specify the ImageID to use or #PB_Any to have the ID returned to you.

Posted: Mon Jun 29, 2009 12:04 pm
by yrreti
Thank you for your reply, and I understand what you mean for the ImageID part.
But equally important is what do you assign *Memory?

netmaestro's picpak gives that information and the code for extracting.
(from my code above:)

Code: Select all

*unpacked = AllocateMemory(58434)
UnpackMemory(?PicPaktriangle, *unpacked)
Global img0 = CatchImage(#img0, *unpacked, 58434)
But I like your idea of putting that info in the data header.
But what do you assign *Memory?
In the first section of your code you have:

Code: Select all

   If Not *Memory
      ProcedureReturn 0
   EndIf
If I don't have a value for *Memory it fails.
I get an ImageGadget drawn, but it is blank.
And how do I tell it to get the Triangle_bmp data?

If you could please just show me a quick example using my code above,
to show me how to use your program. I would really appreciate it.
Because I would really like to be able to use your program.
Thank you for your help

Posted: Wed Jul 01, 2009 6:43 am
by Mistrel
*Memory is the address from your datasection. As per your example, "?PicPaktriangle".

Posted: Wed Jul 01, 2009 12:13 pm
by yrreti
Thank you for your reply, but that is one of the first things I tried, ?Triangle_bmp in place of *Memory, and it didn't work.
I also tried many different combinations by comparing to the other method, and just get either a blank gadget or
a gadget with a thin horizontal line. That's why I'm asking. No one know how a program works better then the
one who wrote it. If you could just jot down a few lines of code using either
Global img1=GetImageResource(#PB_Any,?Triangle_bmp)
ImageGadget(#Image_1, 350, 10, 140, 120, img1, #PB_Image_Border)
or what ever I need to use to use your program, I would be most appreciative. Nothing I've tried works.
At least then I'll see how it works too. Thank you for your help

Posted: Wed Jul 01, 2009 8:51 pm
by Mistrel
Try displaying the image or writing it to disk to be sure there isn't any problem with your code. What OS are you using? When I wrote this I was using XP x32 and I think it was before the introduction of integers. So it might need to be updated for other platforms for 64-bit operating systems.

Try using the Windows 32-bit compiler and see if it works, if you're not using it already.