Page 1 of 2
loading images and mixing
Posted: Mon May 12, 2014 8:41 am
by heaven6502
I am using PureBasic for rapid development and testing for my 8bit 6502 projects.
What I am trying now for weeks is
having a screen open for gfx output, loading 2 images which I want to copy on the openened screen. these are textures where I refer to with point(x,y).
Code: Select all
OpenScreen(640,480,32,"test",0)
CreateImage(0, 320, 320)
CreateImage(1, 320, 320)
LoadImage(0,"texture1.bmp")
loadImage(1,"texture2.bmp")
...
so how can I copy the bitmaps to the opened screen? as I want to actually see them and getting them via Point command... I tried GrabImage, too etc...
I do not get the pic IDs.
Re: loading images and mixing
Posted: Mon May 12, 2014 9:08 am
by heaven6502
[img]
http://formatwar.net/forums/download/fi ... beaba4e79e
[/img]
so actually I want to place a texture where the "bars" are...
Re: loading images and mixing
Posted: Mon May 12, 2014 9:18 am
by Demivec
heaven6502 wrote:so how can I copy the bitmaps to the opened screen? as I want to actually see them and getting them via Point command... I tried GrabImage, too etc...
Code: Select all
OpenScreen(640,480,32,"test",0)
CreateImage(0, 320, 320)
CreateImage(1, 320, 320)
LoadImage(0,"texture1.bmp")
loadImage(1,"texture2.bmp")
;...
StartDrawing(ScreenOutput())
DrawImage(ImageID(0), 0, 0)
DrawImage(ImageID(1), 10, 10)
StopDrawing()
heaven6502 wrote:so actually I want to place a texture where the "bars" are...
You can use alpha layer as a way to combine things. You also may want to use sprites and take advantage of the sprite blending methods.
Re: loading images and mixing
Posted: Mon May 12, 2014 9:23 am
by infratec
Btw.:
If you use LoadImage() you don't need to create them before.
And if you want to use a 'normal' window you can use
ImageGadget(0, 10, 10, 0, 0, ImageID())
Bernd
Re: loading images and mixing
Posted: Mon May 12, 2014 9:31 am
by heaven6502
thx. but I only get a white screen on OSX...
can not be so difficult...

Using 5.22.
Re: loading images and mixing
Posted: Mon May 12, 2014 9:33 am
by heaven6502
Code: Select all
OpenScreen(1024,768,32,"test",RGB(0,0,0))
texture=LoadImage(#PB_Any,"neptunemap.jpg")
StartDrawing(ScreenOutput())
DrawImage(ImageID(texture), 0, 0)
StopDrawing()
Repeat:Until 1=0
won't work...
Re: loading images and mixing
Posted: Mon May 12, 2014 9:39 am
by DK_PETER
Code: Select all
InitSprite()
InitKeyboard()
UseJPEGImageDecoder() ; <--- Remember decoder
Scr = OpenScreen(1024, 768, 32, "Draw on screen", #PB_Screen_SmartSynchronization, 60)
im1 = LoadImage(#PB_Any, "E:\1.jpg")
im2 = LoadImage(#PB_Any, "E:\2.jpg")
Repeat
ClearScreen(0)
StartDrawing(ScreenOutput())
DrawImage(ImageID(im1),0, 0)
DrawImage(ImageID(im2),500,0)
StopDrawing()
ExamineKeyboard()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
Re: loading images and mixing
Posted: Mon May 12, 2014 9:57 am
by heaven6502
thx. seem to work...

I thought that sprite is for "sprites" only
one of my mistake was not saving the source code so the path to the pic did not work (but compiler did not throw an error...)
Re: loading images and mixing
Posted: Mon May 12, 2014 10:00 am
by Danilo
Sprites are better for (Windowed)Screen. And it is hardware accelerated if you need animations.
If you just need to display 2 images, a CanvasGadget or 2 ImageGadget could be enough.
Re: loading images and mixing
Posted: Mon May 12, 2014 12:11 pm
by heaven6502
and how would this work with imagegadget?
Re: loading images and mixing
Posted: Mon May 12, 2014 2:08 pm
by infratec
Hi,
as I told you in my former posting:
Code: Select all
UseJPEGImageDecoder() ; <--- Remember decoder
OpenWindow(0, 0, 0, 1024, 768, "Draw", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
im1 = LoadImage(#PB_Any, "E:\1.jpg")
im2 = LoadImage(#PB_Any, "E:\2.jpg")
ImageGadget(0, 0, 0, 0, 0, ImageID(im1))
ImageGadget(1, 500, 0, 0, 0, ImageID(im2))
Exit = #False
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Exit = #True
EndSelect
Until Exit
Re: loading images and mixing
Posted: Mon May 12, 2014 3:56 pm
by heaven6502
thanks... got it... could not test right now following...
when I do a color=point(x,y) I get the right color doesn't matter if I am over imagegadget1 or 2?
Re: loading images and mixing
Posted: Mon May 12, 2014 4:00 pm
by infratec
No.
Point() is not usable with an ImageGadget().
It is only usable with the image itself.
And for Point() you need StartDrawing() StopDrawing().
Read a bit more in the helpfile.
Bernd
Re: loading images and mixing
Posted: Mon May 12, 2014 4:02 pm
by heaven6502
when I am using plot/point in that example Purebasic crashes.
Re: loading images and mixing
Posted: Mon May 12, 2014 4:04 pm
by heaven6502
ok...
so how would you then solve my potential task?
load different bitmaps on 1 screen (so I can see them). and then getting pixel values with a function and draw on the same screen all at aonce?