Qbasicnews.com
April 12, 2021, 07:57:44 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 [3]
  Print  
Author Topic: Antialiasing  (Read 12253 times)
yetifoot
Ancient Guru
****
Posts: 575



« Reply #30 on: February 12, 2006, 02:47:13 AM »

i would say that if you are using a 3x3 doodah, then you would do

For x = 1 To Width - 2

because otherwise you will attempt to read pixels that don't exist
Logged

EVEN MEN OF STEEL RUST.
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #31 on: February 12, 2006, 12:44:08 PM »

Quote from: "Dr_Davenstein"
Hmm... almost got it. Look at this line again... Wink

IF EndY>=ScreenWidth THEN EndY=ScreenHeight - 1
SON OF A &*^$#!!!

Code:
'BlurPixel.Bas
'By Zachary Vernon
'Contains BlurPixel function, an essential TYPE, and the function declaration.
'Date (mm/dd/yy): 02/10/06
'Usage: BlurPixel (X,Y,I)
'       Returns a Pixel TYPE with the R, G and B value for the blurred
'       version of pixel (X,Y), with I  blurring intensity. I must be > 0, otherwise it is
'       set to 1.
'       Pixel TYPE contains three variables: R, G and B, each representing
'       the red, green and blue value of a pixel.
'       IMPORTANT: Colour depth must be 16 bits or higher, otherwise BlurPixel()
'                  returns -1 for R, G and B.
TYPE Pixel
    R AS INTEGER
    G AS INTEGER
    B AS INTEGER
END TYPE
DECLARE FUNCTION BlurPixel (INTEGER,INTEGER,INTEGER) AS Pixel
FUNCTION BlurPixel (X AS INTEGER,Y AS INTEGER,Intensity AS INTEGER) AS Pixel
    DIM AS Pixel RetPixel
    DIM AS INTEGER StartX,EndX,StartY,EndY,CDepth,ScreenHeight,ScreenWidth,FX,FY,PHits,C
    IF Intensity<=0 THEN Intensity=1
    StartX=X-Intensity
    EndX=X+Intensity
    StartY=Y-Intensity
    EndY=Y+Intensity
    SCREENINFO ScreenWidth,ScreenHeight,CDepth
    IF CDepth=8 THEN
        RetPixel.R=-1
        RetPixel.G=-1
        RetPixel.B=-1
        RETURN RetPixel
    END IF
    IF StartX<=0 THEN StartX=0
    IF EndX>=ScreenWidth THEN EndX=ScreenWidth - 1
    IF StartY<=0 THEN StartY=0
    IF EndY>=ScreenHeight THEN EndY=ScreenHeight - 1
    FOR FX=StartX TO EndX
        FOR FY=StartY TO EndY
            C=POINT(FX,FY)
            RetPixel.R+=(C AND &HFF0000) SHR 16
            RetPixel.G+=(C AND &HFF00) SHR 8
            RetPixel.B+=(C AND &HFF)
            PHits+=1
        NEXT
    NEXT
    RetPixel.R/=PHits
    RetPixel.G/=PHits
    RetPixel.B/=PHits
    RETURN RetPixel
END FUNCTION
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #32 on: February 12, 2006, 04:51:09 PM »

Quote from: "Zack"
Quote from: "Dr_Davenstein"
Hmm... almost got it. Look at this line again... Wink

IF EndY>=ScreenWidth THEN EndY=ScreenHeight - 1
SON OF A &*^$#!!!


:rotfl:
Good job.
Logged
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!