loading images and mixing

Just starting out? Need help? Post your questions and find answers here.
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

loading images and mixing

Post 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.
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post by heaven6502 »

[img]
http://formatwar.net/forums/download/fi ... beaba4e79e
[/img]

so actually I want to place a texture where the "bars" are...
User avatar
Demivec
Addict
Addict
Posts: 4266
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: loading images and mixing

Post 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.
infratec
Always Here
Always Here
Posts: 7599
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: loading images and mixing

Post 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
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post by heaven6502 »

thx. but I only get a white screen on OSX...

can not be so difficult... ;) Using 5.22.
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post 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...
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: loading images and mixing

Post 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)
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post 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...)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: loading images and mixing

Post 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.
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post by heaven6502 »

and how would this work with imagegadget?
infratec
Always Here
Always Here
Posts: 7599
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: loading images and mixing

Post 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
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post 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?
infratec
Always Here
Always Here
Posts: 7599
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: loading images and mixing

Post 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
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post by heaven6502 »

when I am using plot/point in that example Purebasic crashes.
heaven6502
User
User
Posts: 20
Joined: Mon Jan 26, 2009 1:43 pm

Re: loading images and mixing

Post 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?
Post Reply