#Include "window9.bi"
Type OB
	Name As String
	NameS As String
	W As Integer
	H As Integer
	Nb As Integer
	Spr As Any Ptr
	handle As HANDLE	
	sizeI As Integer
End Type
Dim a As OB
a.Name=OpenFileRequester("",GetCurentdir,"Image files (*.bmp)"+Chr(0)+"*.bmp"+Chr(0))
a.NameS=SaveFileRequester("",GetPathPart(a.Name),"Dat files (*.dat, *.*)"_
+Chr(0)+"*.dat;*.*"+Chr(0))
If a.Name<>"" Then
	a.handle=Read_File(a.Name)
	Set_File_Pointer(a.handle,18)
	a.W=Read_Integer(a.handle)
	a.H=Read_Integer(a.handle)
	Set_File_Pointer(a.handle,28,FILE_BEGIN)
	a.Nb=Read_WORD(a.handle)
	Close_File(a.handle)
EndIf
If a.Nb>=24 Then a.Nb=32
If a.NameS<>"" Then
	ScreenRes 320,200, a.Nb
	a.Spr=ImageCreate(a.W,a.H)		
	BLoad(a.Name,a.Spr)
	a.handle=Create_File(a.NameS )
	If a.handle<>-1 Then
		ImageInfo(a.Spr,,,,,,a.sizeI)
		For x As Integer= 0 To a.sizeI
			Write_byte(a.handle,Cast(Byte Ptr, a.Spr )[x])		
		Next
		Close_file(a.handle)
	EndIf
	Beep()
	ImageDestroy(a.Spr)
EndIf
