Eine kleine Library für Bilder mit 3 Bit Graustufen
mit oder ohne Alpha-Channel
Alle Bilder können als 'NIF-Image' abgespeichert werden.
Beispiel:
Code: Alles auswählen
EnableExplicit
Import "nif.lib"
nifLoad.i(File.s);<- load nif/bmp images
nifCatch.i(*Buffer,BufferSize.i);<- catch nif/bmp images
nifConvert.i(*Handle);<- convert img to nif
nifWidth(*NIF);<- get nif width
nifHeight(*NIF);<- get nif height
nifAlpha(*NIF);<- has alpha channel?
nifHandle.i(*NIF);<- get handle
nifSave.i(*NIF,File.s,Bitmap.i = #False);<- save nif/bmp
nifFree.i(*NIF);<- free nif
nifVersion.i();<- version info
EndImport
UsePNGImageDecoder();<- nif only supports bmp/nif files - use image plugins!
UseJPEGImageDecoder()
Global nifImage1.i
Global nifImage2.i
Global nifImage3.i
Procedure.i DownloadAndConvertImage(Url.s);<- download and convert example images
Protected *Buffer
Protected Image.i
Protected Result.i
*Buffer = ReceiveHTTPMemory(Url)
If *Buffer
Image = CatchImage(#PB_Any,*Buffer,MemorySize(*Buffer))
If Image
Result = nifConvert(ImageID(Image))
FreeImage(Image)
EndIf
FreeMemory(*Buffer)
EndIf
ProcedureReturn Result
EndProcedure
If InitNetwork()
nifImage1 = DownloadAndConvertImage("https://upload.wikimedia.org/wikipedia/commons/4/4f/Orion_Belt.jpg")
If nifImage1
nifImage2 = DownloadAndConvertImage("https://www.purebasic.fr/english/styles/subsilverPlus/imageset/purebasic_logo.png")
If nifImage2
nifImage3 = DownloadAndConvertImage("https://upload.wikimedia.org/wikipedia/commons/6/6a/Sputnik-stamp-ussr.jpg")
If nifImage3
Debug nifSave(nifImage1,"nifImage1.nif");<- save nif image (compare sizes!)
If OpenWindow(0,0,0,400,200,"NIF-Image (3 Bit Grayscale Image Library) Demo!",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
If StartVectorDrawing(WindowVectorOutput(0))
MovePathCursor(0,0)
DrawVectorImage(nifHandle(nifImage1),$FF,400,200)
MovePathCursor(60,150)
RotateCoordinates(60,150,-20)
DrawVectorImage(nifHandle(nifImage2),$AA)
MovePathCursor(100,20)
RotateCoordinates(100,20,50)
DrawVectorImage(nifHandle(nifImage3),$AA,50,80)
StopVectorDrawing()
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
CloseWindow(0)
EndIf
nifFree(nifImage3)
EndIf
nifFree(nifImage2)
EndIf
nifFree(nifImage1)
EndIf
EndIf
End
https://www.dropbox.com/s/t2mzhat88uqzb ... a.zip?dl=0
Viel Spass beim testen
Fragen sind wie immer Willkommen