Jump to content

blur an image ?


 Share

Recommended Posts

Hi

I was wondering if there's a way to blur an image, I tried using GDI+ Graphic Functions But I can't save it and it

All blurring happens on the screen only, tried prospeed but I couldn't understand it, finally

Searched the internet looking for an image blur tool with no success.

also , i wanted to know if there's a way to use a bitmap resource in dll

thanx in advance

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

well i use this now but i was wondering if there's another way

the code i am using got it from here :

#458911

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

change autoit_builder_wall_800x600.jpg with your own picture

#include <Prospeed30.au3>

Opt("GUIOnEventMode", 1)
HotKeySet("{Esc}","_Exit")

$Gui = GUICreate("Blur", 800, 600)
GUISetOnEvent(-3, "_exit")
GUISetState()

$hdc = GetHDC()

$image = LoadFileImage("autoit_builder_wall_800x600.jpg")
$array = InitFx($image)

For $i = 1 To 50
    blur($hdc,0,0,$array)
    Sleep(10)
Next

While 1
    Sleep(1000)
WEnd

Func _exit()
    Exit
EndFunc
Link to comment
Share on other sites

thanx man but this draws blur on the screen and i want to be in file

any way i will keep modifying on this script until i make blur the image in the file

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

saves the effect as jpg or bmp to disk

#include <Prospeed30.au3>

Opt("GUIOnEventMode", 1)

$Gui = GUICreate("blur", 800, 600)
GUISetState()

$hdc = GetHDC()

$image  = LoadFileImage("autoit_builder_wall_800x600.jpg")
$array  = InitFx($image)
$bitmap = CreateImage(800,600)

For $i = 1 To 30
    blur($bitmap,0,0,$array)
Next

;SaveImage(bitmapdata, "path+filename", bmp/jpg, Quality for jpg format)
SaveImage($bitmap, "C:\blurpicture.jpg", 1, 10)  ; save as jpg
;SaveImage($bitmap, "C:\blurpicture.bmp", 0, 10) ; save as bmp

Exit
Link to comment
Share on other sites

Hmm...very interesting, example with GDIPlus, technique is to resize the original image to a MUCH SMALLER size, and then resize it to the original size ;)

#include <GDIPlus.au3>

_GDIPlus_Startup()

$file = "c:\runner.jpg"

$ResFile = _ImageResize($file)

_GDIPlus_Shutdown()

Func _ImageResize($sFile, $sReduce = 2)
    Local $hSourceIMG, $iWidth, $iHeight, $hBitmap, $hImage, $hGraphics, $iOutput = @ScriptDir & "\reduced.jpg"
    
    $hSourceIMG = _GDIPlus_ImageLoadFromFile($sFile)
    
    $iWidth = _GDIPlus_ImageGetWidth($hSourceIMG)
    $iHeight = _GDIPlus_ImageGetHeight($hSourceIMG)
    
    $hBitmap = _CreateBMP($iWidth / $sReduce, $iHeight / $sReduce)
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)

    _GDIPLus_GraphicsDrawImageRect($hGraphics, $hSourceIMG, 0, 0, $iWidth / $sReduce, $iHeight / $sReduce)
    _GDIPlus_ImageSaveToFile($hImage, $iOutput)

    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_ImageDispose($hSourceIMG)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    
    $hSourceIMG = _GDIPlus_ImageLoadFromFile($iOutput)
    
    $hBitmap = _CreateBMP($iWidth, $iHeight)
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
    
    _GDIPLus_GraphicsDrawImageRect($hGraphics, $hSourceIMG, 0, 0, $iWidth, $iHeight)
    _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\blur_factor" & $sReduce & ".jpg")
    
    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_ImageDispose($hSourceIMG)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    FileDelete($iOutput)
EndFunc   ;==>_ImageResize

Func _CreateBMP($sWidth, $sHeight)
    Local $hWnd = _WinAPI_GetDesktopWindow()
    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $sWidth, $sHeight)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return $hBMP
EndFunc   ;==>_CreateBMP

Original:

Posted Image

blur by factor 2

Posted Image

blur by factor 3

Posted Image

blur by factor 4

Posted Image

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...