You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


Image Pixelation Filter
08-15-2017, 04:54 AM
Post: #1
 (Print Post)
Image Pixelation Filter
Hi Everyone! Smile
This is a simple pixelation filter which I coded today.
I hope you will like it.
Here's the code. You will need tree.jpg from the attachment or you can use another image by modifying the code. Wink

Code Snippet: [Select]
screen _newimage(600,600,32)

myImage& = _loadimage("tree.jpg")
_putimage , myImage&
dim image2&
do
   while _mouseinput : wend
    amount = map(_mousex, 0, 600, 1, 50)
    
    if amount <> p_amount then
        p_amount = amount
        if image2& < -1 then _freeimage image2&
        image2& = pixelateImage(myImage&, amount)
        _putimage , image2&
    end if
    
    _display
    _limit 40
loop

function pixelateImage& (original_image as long, amount as integer)
   if original_image > -1 then print "[pixelateImage() Error Message]":print "Invalid Image Handle":exit function
    if amount = 0 then print "[pixelateImage() Error Message]": print "amount = 0": exit function
    
   $CHECKING:OFF
    
    pixelateImage& = _newimage(_width(original_image), _height(original_image), 32)
    
    _dest pixelateImage&
    _source original_image
    
    for y = amount to _height(original_image) - 1 step amount
        for x = amount to _width(original_image) - 1 step amount
            col& = point(x,y)
            line (x-amount, y-amount)-step(amount,amount),col&,bf
        next
    next
    
   $checking:on
    _dest 0
    _source 0
end function

FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
   map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
END FUNCTION


Some screenshots are -
[Image: c33f0e.png]

[Image: 17e5ad.png]


Attached File(s) Image(s)
   
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Quarto
QB64 Member Project - Pivot version two
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Input
QB64 Member Project - Rubix's Magic
QB64 Member Project - Domain
QB64 Member Project - Color Triangles
QB64 Member Project - ARB Checkers
QB64 Member Project - Splatter
QB64 Member Project - Bowditch curve
QB64 Member Project - Touche
QB64 Member Project - Connect Four
QB64 Member Project - Color Rotating Text
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Overboard
QB64 Member Project - Amazon
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Score 4
QB64 Member Project - Foursight
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Sabotage
QB64 Member Project - Blokus
QB64 Member Project - Line Thickness
QB64 Member Project - Dreamy Clock
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Martin Fractals version four
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Exit
QB64 Member Project - Rotating Background
QB64 Member Project - Spiro Roses
QB64 Member Project - Dakapo
QB64 Member Project - Pivet version one
QB64 Member Project - Martin Fractals version three
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - Othello
QB64 Member Project - Inside Moves
QB64 Member Project - 9 Board
QB64 Member Project - Algeria Weather
QB64 Member Project - Martin Fractals version two
QB64 Member Project - Point Blank
QB64 Member Project - Kings Court
QB64 Member Project - Basic Dithering
QB64 Member Project - Qubic
QB64 Member Project - Isolation
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Swirl