Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blending two images
#7
(02-28-2023, 05:59 PM)TerryRitchie Wrote: I played around with this for a while and this is the best I could come up with:

Code: (Select All)
DIM Image AS LONG '       alpha image
DIM i AS INTEGER '        for/next loop counter
DIM Pulse AS INTEGER '    number of times to overlay image
DIM PulseDir AS INTEGER ' inc/dec pulse counter

Image = _LOADIMAGE("tam1-4.png", 32) '                     load alpha image
ImageLeft = _NEWIMAGE(130, 288, 32) '                      left image holder
ImageRight = _NEWIMAGE(130, 288, 32) '                     right image holder
_PUTIMAGE (0, 0), Image, ImageLeft '                       create left image
_PUTIMAGE (0, 0), Image, ImageRight, (74, 0)-(203, 287) '  create right image

SCREEN _NEWIMAGE(640, 480, 32) '                           graphics screen
Pulse = 0 '                                                initialize variables
PulseDir = 1
DO '                                                       begin pulse loop
    _LIMIT 30 '                                            30 frames per second
    CLS
    Pulse = Pulse + PulseDir '                             increment/decrement pulse amount
    IF Pulse > 10 OR Pulse < 1 THEN PulseDir = -PulseDir ' reverse pulse adder
    FOR i = 1 TO Pulse '                                   loop the number of pulses
        _PUTIMAGE (32, 0), Image '                         overlay alpha image over and over
    NEXT i
    _PUTIMAGE (0, 0), ImageLeft '                          overlay left image
    _PUTIMAGE (130, 0), ImageRight '                       overlay right image
    _DISPLAY '                                             update screen
LOOP UNTIL _KEYDOWN(27) '                                  ESC to end


By playing around with the amount of left and right image used you can draw the white beams closer or farther apart. By overlaying the original image in between the two outer images you can create a pulsing effect showing your ion engines increasing/decreasing in power. This also softens the slightly darker line in between the left and right image that no matter how hard I try I can't get rid of.

I took your image and processed two of them overlapping side by side in a few paint programs I have. The result is always the same as what QB64 does, so QB64 is actually blending them properly.
Thank you very much TerryRitchie!!! I think I will reuse your code Smile Smile Smile
10 PRINT "Hola! Smile"
20 GOTO 10
Reply


Messages In This Thread
Blending two images - by Ikerkaz - 02-28-2023, 09:21 AM
RE: Blending two images - by bplus - 02-28-2023, 02:53 PM
RE: Blending two images - by Petr - 02-28-2023, 03:59 PM
RE: Blending two images - by Ikerkaz - 02-28-2023, 04:23 PM
RE: Blending two images - by bplus - 02-28-2023, 05:41 PM
RE: Blending two images - by TerryRitchie - 02-28-2023, 05:59 PM
RE: Blending two images - by Ikerkaz - 02-28-2023, 07:03 PM
RE: Blending two images - by TerryRitchie - 02-28-2023, 07:21 PM
RE: Blending two images - by Ikerkaz - 03-03-2023, 07:49 AM
RE: Blending two images - by Ikerkaz - 03-03-2023, 09:23 AM



Users browsing this thread: 2 Guest(s)