Author Topic: Program drops when putting an image in another image  (Read 4429 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Program drops when putting an image in another image
« Reply #15 on: August 06, 2019, 07:40:18 am »
Question:  Is the use of _PUTIMAGE really something required here?

This seems like a much simpler process:
Code: QB64: [Select]
  1. Main& = _NEWIMAGE(200, 200, 32)
  2. Inner& = _NEWIMAGE(24, 24, 32)
  3. SCREEN Main&
  4. COLOR _RGBA32(255, 255, 255, 255), _RGBA32(127, 127, 127, 255)
  5.     CLS
  6.     PRINT "Let us make a box."
  7.     PRINT "Yes, let us."
  8.     Box 100, 100, _RGBA32(0, 0, 255, 255)
  9.     BoxInBox 50, 100, _RGBA32(0, 0, 255, 255), _RGBA32(255, 0, 0, 255)
  10.     x = x + 1
  11.     LOCATE 12, 1
  12.     PRINT "Loop: "; x;
  13.     _DISPLAY
  14.     _LIMIT 2000
  15.  
  16. SUB Box (x1, y1, kolor AS _UNSIGNED LONG)
  17.     LINE (x1, y1)-STEP(24, 24), kolor, BF
  18.  
  19. SUB BoxInBox (x1, y1, outerkolor AS _UNSIGNED LONG, innerkolor AS _UNSIGNED LONG)
  20.     LINE (x1, y1)-STEP(24, 24), outerkolor, BF
  21.     LINE (x1 + 4, y1 + 4)-STEP(15, 15), innerkolor, BF
  22.  
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Program drops when putting an image in another image
« Reply #16 on: August 06, 2019, 08:08:02 am »
Thanks Steve, that's a much more elegant solution than trying to figure out where to free image after the fact.

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Program drops when putting an image in another image
« Reply #17 on: August 06, 2019, 08:12:49 am »
Question:  Is the use of _PUTIMAGE really something required here?

In the main program I was using _PRINTSTRING to place a number in the box, it seemed that using sub images was easier in that instance.