Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Summer LASER Challenge
#14
Ok, thanks to the replies I received I realized a bloom is what I need, more specifically Gaussian blurring. Instead of recreating code for Gaussian blurs I've been using @RhoSigma 's excellent Image Processing Library which includes a few methods for Gaussian blurring. His blurring routines also preserve the alpha channel which is a HUGE plus! The code below is a proof of concept I came up with. You'll need the image and library .BM file below to execute the code.

Code: (Select All)

' Bloom test 1
' Uses RhoSigma's Image Processing Library (imageprocess.bm)

DIM TestImage AS LONG
DIM NoAlphaImage AS LONG
DIM AlphaImage AS LONG
DIM FirstPass AS LONG
DIM SecondPass AS LONG
DIM Alpha AS INTEGER
DIM Red AS INTEGER
DIM Green AS INTEGER
DIM Blue AS INTEGER
DIM x AS INTEGER
DIM y AS INTEGER
DIM i AS INTEGER

TestImage = _LOADIMAGE("test.png", 32) '                            27 x 53 original image
AlphaImage = _NEWIMAGE(_WIDTH(TestImage), _HEIGHT(TestImage), 32) ' empty image same size as original

RANDOMIZE TIMER
SCREEN _NEWIMAGE(640, 480, 32)

'+-----------------------------------+
'| Create quick and dirty background |
'+-----------------------------------+

FOR i = 1 TO 200
    LINE (RND * 640, RND * 480)-(RND * 640, RND * 480), _RGB32(RND * 256, RND * 256, RND * 256)
NEXT i

'+-------------------------------------------------------------------------+
'| Copy TestImage to AlphaImage at the same time applying the alpha levels |
'+-------------------------------------------------------------------------+

_DEST AlphaImage
_SOURCE TestImage
FOR y = 0 TO _HEIGHT(TestImage) - 1

    '+------------------------------------------+
    '| Draw center vertical strip with no alpha |
    '+------------------------------------------+

    Alpha = 255
    Red = _RED(POINT(13, y))
    Green = _GREEN(POINT(13, y))
    Blue = _BLUE(POINT(13, y))
    IF Red OR Green OR Blue THEN '                            don't copy pixel if value is (0,0,0)
        PSET (13, y), _RGB32(Red, Green, Blue, Alpha)
    END IF

    FOR x = 12 TO 0 STEP -1

        '+------------------------------------------------------------------------+
        '| Draw vertical strips to right and left of center with decreasing alpha |
        '+------------------------------------------------------------------------+

        Alpha = Alpha - 10
        Red = _RED(POINT(x, y))
        Green = _GREEN(POINT(x, y))
        Blue = _BLUE(POINT(x, y))
        IF Red OR Green OR Blue THEN '                        don't copy pixel if value is (0,0,0)
            PSET (x, y), _RGB32(Red, Green, Blue, Alpha)
            PSET (26 - x, y), _RGB32(Red, Green, Blue, Alpha)
        END IF
    NEXT x
NEXT y
_DEST 0
_SOURCE 0

NoAlphaImage = ApplyFilter&(TestImage, "gauss8", 0, 0, -1, -1, -1, -1, -1)
FirstPass = ApplyFilter&(AlphaImage, "gauss8", 0, 0, -1, -1, -1, -1, -1)
SecondPass = ApplyFilter&(FirstPass, "gauss8", 0, 0, -1, -1, -1, -1, -1)

_PUTIMAGE (100, 100), TestImage '      original untouched image
_PUTIMAGE (125, 100), NoAlphaImage '    TestImage blurred once with no alpha applied
_PUTIMAGE (150, 100), AlphaImage '      TestImage with alpha applied (no blurring)
_PUTIMAGE (175, 100), FirstPass '      AlphaImage blurred once
_PUTIMAGE (200, 100), SecondPass '      AlphaImage blurred a second time

'$INCLUDE:'imageprocess.bm'


Attached Files Image(s)
   

.bm   imageprocess.bm (Size: 56 KB / Downloads: 57)
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Summer LASER Challenge - by TerryRitchie - 07-15-2023, 07:32 PM
RE: Summer LASER Challenge - by bplus - 07-15-2023, 08:10 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-15-2023, 09:48 PM
RE: Summer LASER Challenge - by justsomeguy - 07-15-2023, 09:27 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-15-2023, 09:49 PM
RE: Summer LASER Challenge - by Dav - 07-15-2023, 11:44 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-16-2023, 01:34 AM
RE: Summer LASER Challenge - by GareBear - 07-15-2023, 11:54 PM
RE: Summer LASER Challenge - by Dav - 07-16-2023, 01:42 AM
RE: Summer LASER Challenge - by TerryRitchie - 07-16-2023, 01:58 AM
RE: Summer LASER Challenge - by bplus - 07-16-2023, 02:34 AM
RE: Summer LASER Challenge - by mnrvovrfc - 07-16-2023, 03:35 AM
RE: Summer LASER Challenge - by bplus - 07-16-2023, 02:21 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 02:12 AM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 02:47 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 02:58 PM
RE: Summer LASER Challenge - by SpriggsySpriggs - 07-17-2023, 03:29 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 04:51 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 04:22 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 04:34 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 05:00 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 06:38 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 06:43 PM
RE: Summer LASER Challenge - by bplus - 07-18-2023, 02:58 PM
RE: Summer LASER Challenge - by bplus - 07-19-2023, 01:14 AM
RE: Summer LASER Challenge - by James D Jarvis - 07-20-2023, 02:28 AM
RE: Summer LASER Challenge - by bplus - 07-20-2023, 12:44 PM
RE: Summer LASER Challenge - by Dav - 07-21-2023, 03:00 AM
RE: Summer LASER Challenge - by bplus - 07-21-2023, 03:56 PM
RE: Summer LASER Challenge - by grymmjack - 07-21-2023, 04:46 PM
RE: Summer LASER Challenge - by bplus - 07-21-2023, 04:59 PM
RE: Summer LASER Challenge - by SierraKen - 07-27-2023, 02:38 AM
RE: Summer LASER Challenge - by bplus - 07-27-2023, 01:49 PM
RE: Summer LASER Challenge - by SierraKen - 07-27-2023, 02:41 AM
RE: Summer LASER Challenge - by TerryRitchie - 07-27-2023, 11:56 PM
RE: Summer LASER Challenge - by Dav - 07-28-2023, 12:48 AM
RE: Summer LASER Challenge - by bplus - 07-28-2023, 01:20 PM
RE: Summer LASER Challenge - by dbox - 07-28-2023, 06:56 PM
RE: Summer LASER Challenge - by bplus - 07-28-2023, 09:23 PM
RE: Summer LASER Challenge - by SierraKen - 07-29-2023, 10:13 PM
RE: Summer LASER Challenge - by OldMoses - 07-30-2023, 01:02 PM
RE: Summer LASER Challenge - by bplus - 07-30-2023, 02:28 PM
RE: Summer LASER Challenge - by bplus - 07-30-2023, 06:57 PM



Users browsing this thread: 4 Guest(s)