Restored from previous forum. Originally posted by halo.
I can load and display image, but have no idea how this is working. I really want to copy the image to a PB image I create, but can't find a command to copy the buffer or anything:
OpenDLL(0,"nviewlib.dll"); Open the DLL
DLLFunction(0,0,"NViewLibLoad"); Register function NViewLibLoad
DLLFunction(1,0,"GetWidth"); Register as function 2
DLLFunction(2,0,"GetHeight"); Register as function 3
File$="test.jpg"
CallDLL2(0,File$,0)
AddrImage.l=DLLNum()
CallDLL0(1):Width.l=DLLNum()+8
CallDLL0(2):Height.l=DLLNum()+28
OpenWindow(0,200,200,Width,Height,#WM_PAINT|#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"")
SetForeGroundWindow_(WindowID())
*dc=GetDC_(WindowID())
*dcm=CreateCompatibleDC_(*dc)
SelectObject_(*dcm,AddrImage)
BitBlt_(*dc,0,0,Width,Height,*dcm,0,0,13369376)
CreateImage(1,width,height)
Repeat
event=WaitWindowEvent()
If event=#WM_PAINT
BitBlt_(*dc,0,0,Width,Height,*dcm,0,0,13369376)
EndIf
Until event=#PB_EventCloseWindow
End
Trying to load an image with Mr. Skunk's libs.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Hmmm... NViewLib, nice.
Loads JPG, JIF, GIF, BMP, DIB, RLE, TGA and PCX
and its free. Now, thats interesting...
NViewLib 1.1.4: http://www.programmersheaven.com/file.asp?FileID=2045
Anyway...
...here a modified version of your source.
I use the internal PureBasic commands for using DLLs,
not the old and bad Skunk commands:
I think its not needed to copy the loaded image
to an internal PureBasic image, but you can do
this easily with this code:
Now you have copied the NView-Image to PB-Image number 1.
Hope this helps.
cya,
...Danilo
(registered PureBasic user)
Hmmm... NViewLib, nice.
Loads JPG, JIF, GIF, BMP, DIB, RLE, TGA and PCX
and its free. Now, thats interesting...
NViewLib 1.1.4: http://www.programmersheaven.com/file.asp?FileID=2045
Anyway...
...here a modified version of your source.
I use the internal PureBasic commands for using DLLs,
not the old and bad Skunk commands:
Code: Select all
Procedure LoadNViewImage(FileName$, *AT_Width, *AT_Height)
OpenLibrary(0,"nviewlib.dll") ; Open the DLL
AddrImage = CallFunction(0,"NViewLibLoad",FileName$,0)
PokeL(*AT_Width, CallFunction(0,"GetWidth"))
PokeL(*AT_Height,CallFunction(0,"GetHeight"))
CloseLibrary(0)
ProcedureReturn AddrImage
EndProcedure
Procedure DrawNViewImage(Image,Output)
StartDrawing(Output)
DrawImage(Image,0,0)
StopDrawing()
EndProcedure
TestImage = LoadNViewImage("test.jpg",@Width,@Height)
OpenWindow(0,200,200,Width,Height,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"")
SetForeGroundWindow_(WindowID())
Repeat
event=WaitWindowEvent()
If event=#WM_PAINT
DrawNViewImage(TestImage,WindowOutput())
EndIf
Until event=#PB_EventCloseWindow
End
to an internal PureBasic image, but you can do
this easily with this code:
Code: Select all
TestImage = LoadNViewImage("test.jpg",@Width,@Height)
; Copy image
myNewImage = CreateImage(1,Width,Height)
DrawNViewImage(TestImage,ImageOutput())
Hope this helps.
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
OK, halo - i think thats better:
You can use this procedure 100% like the LoadImage()
command from PureBasic, but load much more different
image formats.
If PB supports CreateSprite() in the next version,
you can modify the procedure a little bit to LoadNViewSprite() -
so you could load JPG,JIF,GIF,BMP,DIB,RLE,TGA and PCX as Sprites.
I think this way is more what you wanted...
cya,
...Danilo
(registered PureBasic user)
OK, halo - i think thats better:
Code: Select all
Procedure LoadNViewImage(ImageNumber,FileName$)
;
; SYNTAX
; ImageHandle = LoadNViewImage(#Image, FileName$)
;
; DESCRIPTION
; Load the specified image.
; The image format can be a JPG, JIF, GIF, BMP, DIB, RLE, TGA or PCX file.
; If the function fails, 0 is returned, Else all is fine.
; This command requires the NVIEWLIB.DLL in the Path.
;
If OpenLibrary(0,"nviewlib.dll")
AddrImage = CallFunction(0,"NViewLibLoad",FileName$,0)
Width = CallFunction(0,"GetWidth"))
Height = CallFunction(0,"GetHeight"))
newImage = CreateImage(ImageNumber,Width,Height)
StartDrawing(ImageOutput())
DrawImage(AddrImage,0,0)
StopDrawing()
DeleteObject_(AddrImage)
CloseLibrary(0)
EndIf
ProcedureReturn newImage
EndProcedure
LoadNViewImage(1,"test.jpg")
OpenWindow(0,200,200,ImageWidth(),ImageHeight(),#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"")
SetForeGroundWindow_(WindowID())
Repeat
event=WaitWindowEvent()
If event=#WM_PAINT
StartDrawing(WindowOutput())
DrawImage(ImageID(),0,0)
StopDrawing()
EndIf
Until event=#PB_EventCloseWindow
End
command from PureBasic, but load much more different
image formats.
If PB supports CreateSprite() in the next version,
you can modify the procedure a little bit to LoadNViewSprite() -
so you could load JPG,JIF,GIF,BMP,DIB,RLE,TGA and PCX as Sprites.
I think this way is more what you wanted...
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
The NView.dll seems very interresting, it's a nice way to load tons of formats easely...
Fred - AlphaSND
For now, you can easely use GrabSprite() exactly like a createsprite() and overwrite the picture...
If PB supports CreateSprite() in the next version,
you can modify the procedure a little bit to LoadNViewSprite() -
so you could load JPG,JIF,GIF,BMP,DIB,RLE,TGA and PCX as Sprites.
The NView.dll seems very interresting, it's a nice way to load tons of formats easely...
Fred - AlphaSND
-
BackupUser
- PureBasic Guru

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

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
>For now, you can easely use GrabSprite() exactly
>like a createsprite() and overwrite the picture...
But can Grabsprite() make Sprites bigger than the current Screen ??
If this works, no CreateSprite() needed anymore...
cya,
...Danilo
(registered PureBasic user)
>For now, you can easely use GrabSprite() exactly
>like a createsprite() and overwrite the picture...
But can Grabsprite() make Sprites bigger than the current Screen ??
If this works, no CreateSprite() needed anymore...
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm