Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Antialiasing
#31
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
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#32
Quote: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
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#33
Quote:
Dr_Davenstein Wrote:Hmm... almost got it. Look at this line again... Wink

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

:rotfl:
Good job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)