Author Topic: Hardware Images won't display: What is this hardware newbie missing?  (Read 3598 times)

0 Members and 1 Guest are viewing this topic.

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
In trying to play around with hardware images, I seem to be having issues getting my own attempts to display. If I cut and paste examples from the wiki or forum, they generally work. My own?...eh...not so much. I can't see what I'm missing that other examples have. Define an image in software, _COPYIMAGE to new handle in mode 33, then put it wherever... If there's something more, I can't see it

In the following snippet of test code, everything works fine in software images, but toggle the comments of the 'Soft_Image' blocks to change to mode 33 and nothing but image handle values will display. The image handles are very "large" values for hardware images. Is that normal, or does it indicate a problem? I presume that I just don't have the requisite understanding of what's going on. Thanks.

OS: Windows 10
QB64 ver. 2.0  07b2101

Code: QB64: [Select]
  1. DIM SHARED flight&, evade&, intercept&, fleet&, break&, cancel&
  2. SCREEN _NEWIMAGE(400, 400, 32)
  3. Make_ButtonsII
  4. 'display the buttons
  5. _PUTIMAGE (20, 16), flight&
  6. _PUTIMAGE (25, 32), evade&
  7. _PUTIMAGE (30, 48), intercept&
  8. _PUTIMAGE (35, 64), fleet&
  9. _PUTIMAGE (40, 80), break&
  10. _PUTIMAGE (45, 96), cancel&
  11. 'check if handles valid
  12. LOCATE 10, 1
  13. PRINT flight&
  14. PRINT evade&
  15. PRINT intercept&
  16. PRINT fleet&
  17. PRINT break&
  18. PRINT cancel&
  19.  
  20. SUB Make_ButtonsII
  21.  
  22.     DIM tmp AS LONG
  23.  
  24.     Soft_Image tmp, 80, 16, "FLIGHTPLAN", &HFF16A6D3: flight& = _COPYIMAGE(tmp, 32): _FREEIMAGE tmp
  25.     Soft_Image tmp, 40, 16, "EVADE", &HFFF40B11: evade& = _COPYIMAGE(tmp, 32): _FREEIMAGE tmp
  26.     Soft_Image tmp, 72, 16, "INTERCEPT", &HFF118B11: intercept& = _COPYIMAGE(tmp, 32): _FREEIMAGE tmp
  27.     Soft_Image tmp, 40, 16, "FLEET", &HFF8B118B: fleet& = _COPYIMAGE(tmp, 32): _FREEIMAGE tmp
  28.     Soft_Image tmp, 40, 16, "BREAK", &HFF8B118B: break& = _COPYIMAGE(tmp, 32): _FREEIMAGE tmp
  29.     Soft_Image tmp, 48, 16, "CANCEL", &HFF434396: cancel& = _COPYIMAGE(tmp, 32): _FREEIMAGE tmp
  30.  
  31.     'Soft_Image tmp, 80, 16, "FLIGHTPLAN", &HFF16A6D3: flight& = _COPYIMAGE(tmp, 33): _FREEIMAGE tmp
  32.     'Soft_Image tmp, 40, 16, "EVADE", &HFFF40B11: evade& = _COPYIMAGE(tmp, 33): _FREEIMAGE tmp
  33.     'Soft_Image tmp, 72, 16, "INTERCEPT", &HFF118B11: intercept& = _COPYIMAGE(tmp, 33): _FREEIMAGE tmp
  34.     'Soft_Image tmp, 40, 16, "FLEET", &HFF8B118B: fleet& = _COPYIMAGE(tmp, 33): _FREEIMAGE tmp
  35.     'Soft_Image tmp, 40, 16, "BREAK", &HFF8B118B: break& = _COPYIMAGE(tmp, 33): _FREEIMAGE tmp
  36.     'Soft_Image tmp, 48, 16, "CANCEL", &HFF434396: cancel& = _COPYIMAGE(tmp, 33): _FREEIMAGE tmp
  37.  
  38. END SUB 'Make_ButtonsII
  39.  
  40.  
  41. SUB Soft_Image (img AS LONG, xpos AS INTEGER, ypos AS INTEGER, label AS STRING, c AS _UNSIGNED LONG)
  42.  
  43.     img = _NEWIMAGE(xpos, ypos, 32)
  44.     _DEST img
  45.     COLOR _RGB32(255), c
  46.     CLS
  47.     _PRINTSTRING (0, 0), label
  48.     _DEST 0
  49.  
  50. END SUB 'Soft_Image
  51.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Hardware Images won't display: What is this hardware newbie missing?
« Reply #1 on: November 06, 2021, 07:42:54 am »
_DISPLAY

Hardware images require a display statement to render.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Hardware Images won't display: What is this hardware newbie missing?
« Reply #2 on: November 06, 2021, 08:04:47 am »
Thanks Steve, but this doesn't work:

_PUTIMAGE (20, 16), flight&
_PUTIMAGE (25, 32), evade&
_PUTIMAGE (30, 48), intercept&
_PUTIMAGE (35, 64), fleet&
_PUTIMAGE (40, 80), break&
_PUTIMAGE (45, 96), cancel&
_DISPLAY


While this does:

DO
    _PUTIMAGE (20, 16), flight&
    _PUTIMAGE (25, 32), evade&
    _PUTIMAGE (30, 48), intercept&
    _PUTIMAGE (35, 64), fleet&
    _PUTIMAGE (40, 80), break&
    _PUTIMAGE (45, 96), cancel&
    _DISPLAY
    _LIMIT 30
LOOP UNTIL _KEYDOWN(27)

Do they only work in display loops?

Ultimately, what I'm looking to do is to define hardware control buttons that don't change, use them as constituents of larger software images that do.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Hardware Images won't display: What is this hardware newbie missing?
« Reply #3 on: November 06, 2021, 12:56:19 pm »
Yes, hardware images really only work in loops. Is there any reason to use hardware images for static animation? When using hardware images, you don't have to worry about background restoration at all, because everything is rendered again and again. To confirm my statement, I enclose a short example, note that nothing is used in the program to restore the software layer (S&) and yet there is no visible trace of the dragged image.

Code: QB64: [Select]
  1. H& = _CopyImage(S&, 33)
  2. Half = _DesktopHeight \ 2
  3.     _PutImage (t - 50, Half - 50)-(t + 50, Half + 50), H&, 0 'insert hardware layer to software layer
  4.     _Display
  5.     _Limit 10
  6.  

BUT, you can also use hardware images in the same way as classical software images and then you need solving hardware background (if you copy hardware images to hardware layers):

Code: QB64: [Select]
  1. H& = _CopyImage(S&, 33)
  2. H2& = _CopyImage(S&, 33)
  3. Half = _DesktopHeight \ 2
  4.     _PutImage (t - 50, Half - 50)-(t + 50, Half + 50), H&, H2& 'copy hardware to hardware
  5.     _PutImage , H2&, 0 'insert hardware layer to software layer
  6.     _Display
  7.     _Limit 10
  8.  
« Last Edit: November 06, 2021, 01:06:21 pm by Petr »

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Hardware Images won't display: What is this hardware newbie missing?
« Reply #4 on: November 06, 2021, 01:21:46 pm »
Thanks Petr,
Yeah it looks like there's no reason to use them in the way I was thinking, but I've got some other projects where they might help a lot.