Author Topic: Create image out of screenlayer  (Read 2486 times)

0 Members and 1 Guest are viewing this topic.

Offline MrFreyer

  • Newbie
  • Posts: 34
Create image out of screenlayer
« on: February 16, 2018, 01:08:25 pm »
Hello,

for making my gamecode more efficent, I would like to create a layer, put my spritetiles on this layer, save this layer as an image, change to the default Destinationlayer and put my saved image as a backgrundimage in every frame. But it doesn't works correctly.
I tried it like this:


_DEST backgroundlayer

FOR y = 1 TO 100
FOR x = 1 TO 100
 _PUTIMAGE (x, y), tilespriteA
NEXT x
NEXT y

backgroundImage = backgroundlayer

_DEST 0

.
.
.

 _PUTIMAGE (x, y), backgroundImage


Thanks

FellippeHeitor

  • Guest
Re: Create image out of screenlayer
« Reply #1 on: February 16, 2018, 01:31:06 pm »
offScreenBuffer = _newimage(desiredWidth, desiredHeight, 32)

SCREEN _newimage(desiredGameWidth, desiredGameHeight, 32)

_DEST offScreenBuffer

FOR y = 1 TO 100
FOR x = 1 TO 100
 _PUTIMAGE (x, y), tilespriteA
NEXT x
NEXT y

_putimage (x, y), offScreenBuffer, _DISPLAY

Offline MrFreyer

  • Newbie
  • Posts: 34
Re: Create image out of screenlayer
« Reply #2 on: February 16, 2018, 02:11:06 pm »
Okay, great.

Is it possible to change later the size of the image, I created with _NEWIMAGE?

Sry, but you know: the wiki is still down... :D

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Create image out of screenlayer
« Reply #3 on: February 16, 2018, 02:23:01 pm »

FellippeHeitor

  • Guest
Re: Create image out of screenlayer
« Reply #4 on: February 16, 2018, 02:24:07 pm »
Okay, great.

Is it possible to change later the size of the image, I created with _NEWIMAGE?

Sry, but you know: the wiki is still down... :D

You'll need to _FREEIMAGE offScreenBuffer and then offScreenBuffer = _newimage(newdesiredWidth, newdesiredHeight, 32)

By the way, we have the wiki at www.qb64.org/wiki

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Create image out of screenlayer
« Reply #5 on: February 17, 2018, 04:31:01 am »
Quote
Okay, great.

Is it possible to change later the size of the image, I created with _NEWIMAGE?

Sry, but you know: the wiki is still down... :D

You'll need to _FREEIMAGE offScreenBuffer and then offScreenBuffer = _newimage(newdesiredWidth, newdesiredHeight, 32)

By the way, we have the wiki at www.qb64.org/wiki

or use _PUTIMAGE and insert your screenBuffer to visible screen (in the same size, or diminished, or enlarged. Or, if you want to make a picture by rotating, use _MAPTRIANGLE.)