Author Topic: Question about transparent images  (Read 4506 times)

0 Members and 1 Guest are viewing this topic.

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Question about transparent images
« Reply #15 on: April 11, 2019, 12:50:42 am »
The use? Ah, humor. _INSTRREV() is the new reverse function to INSTR(). So, I thought if I inserted that at the end of your code, I could get the .png to reappear. :D

Pete

Lol!

FellippeHeitor

  • Guest
Re: Question about transparent images
« Reply #16 on: April 11, 2019, 12:53:05 am »
Quote
Is there an official place to submit feature requests?

Yes. Both for feature requests and bug reports: https://github.com/Galleondragon/qb64/issues

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Question about transparent images
« Reply #17 on: April 11, 2019, 12:54:14 am »
The use? Ah, humor. _INSTRREV() is the new reverse function to INSTR(). So, I thought if I inserted that at the end of your code, I could get the .png to reappear. :D

Pete
Oh man! You are always happy and want to make everyone laugh with your jokes.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Question about transparent images
« Reply #18 on: April 11, 2019, 02:28:25 am »
Is this what you want?
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2.  
  3. img& = _LOADIMAGE("rainbow.png")
  4.  
  5. FOR i = 0 TO 255
  6.     CLS
  7.     addAlpha2Img img&, -1 'subtract 1 alpha value from each pixel.
  8.     _PUTIMAGE (0, 0)-(600, 600), img&
  9.     _LIMIT 40
  10.     _DISPLAY
  11.  
  12.  
  13. SUB addAlpha2Img (img&, alpha AS INTEGER)
  14.     IF img& >= -1 THEN EXIT SUB
  15.     DIM buffer AS _MEM, o AS _OFFSET, o2 AS _OFFSET
  16.     buffer = _MEMIMAGE(img&)
  17.     o = buffer.OFFSET
  18.     o2 = o + _WIDTH(img&) * _HEIGHT(img&) * 4
  19.     DO
  20.         b = _MEMGET(buffer, o + 3, _UNSIGNED _BYTE)
  21.         IF (b + alpha) > 0 AND (b + alpha) < 255 THEN
  22.             _MEMPUT buffer, o + 3, (b + alpha) AS _UNSIGNED _BYTE
  23.         END IF
  24.         o = o + 4
  25.     LOOP UNTIL o = o2
  26.     _MEMFREE buffer
  27.  


That code does do what I wanted.  I will go through your code later, and work out what exactly it's doing.

It also seems to be going pretty fast when I tried it over a background image, appears to maintain 60FPS without issue at 600x600.

Thank you kindly for your help.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Question about transparent images
« Reply #19 on: April 11, 2019, 02:34:10 am »
While you fiddle with it, disable (REM out) the  $CHECKING lines.  $CHECKING:OFF makes it run faster, but it sacrifices the debugging messages. Only use  $CHECKING:OFF when you have debugged, ready to use code.

Would you believe Ashish is only 16? If you have time, search for some of his 3-D Open-GL projects on the boards.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Question about transparent images
« Reply #20 on: April 11, 2019, 02:44:40 am »
By debugging messages, do you mean things like error messages with line numbers, or what exactly?

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Question about transparent images
« Reply #21 on: April 11, 2019, 01:22:23 pm »
Best described here: http://www.qb64.org/wiki/$CHECKING
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Jack002

  • Forum Regular
  • Posts: 123
  • Boss, l wanna talk about arrays
    • View Profile
Re: Question about transparent images
« Reply #22 on: April 19, 2019, 10:38:29 am »
The use? Ah, humor. _INSTRREV() is the new reverse function to INSTR(). So, I thought if I inserted that at the end of your code, I could get the .png to reappear. :D

Pete
If I do a DIR listing with INSTRREV will I be able to see deleted files?
:D
QB64 is the best!