UEZ

[GAME] AUTOITEROIDS v1.019 Build 2016-01-14 Final

55 posts in this topic

#1 ·  Posted (edited)

Here my 1st game ever.

 

A try to remake of the arcade classical 2D game Asteroids® by Atari (1979). :D

 

More information about Asteroids® here or here!

 

Play online here :idea:

 

 

Please don't link to file below directly from other websites!

 

Downloads (2263 previously):  AUTOITEROIDS v1.019 Build 2016-01-14.7z (use e.g. 7-Zip to extract archive)

 

Only compiled version incl. needed files here: <4shared.com> or <MediaFire.com>

 

 

post-29844-1242504010_thumb.png

 

 

 

LEGAL NOTICE:

 

This game is an unoffical clone of the original Asteroids®

game and is not endorsed by the registered trademark

and copyright owners Atari Interactive, Inc.

 

 

 

Short description:

 

AUTOITEROIDS is a remake of the video arcade game released in 1979 by Atari, Inc.

It was one of the most popular and influential games of the Golden Age of Arcade Games.

The player controls a spaceship in an asteroid field which is periodically traversed by flying saucers.

The object of the game is to shoot and destroy asteroids and saucers while not colliding with either,

or being hit by the saucers' counter-fire.

 

 

Keys:

 

ctrl - shoot,

up - thrust,

left - turn left,

right - turn right,

space - hyper jump

 

 

Game details:

 

game is starting with 3 asteroids

every 10.000 points increase of level (among other things amount of asteroids + 1)

every 30.000 points extra live

biggest asteroid = 20 points

medium asteroid = 50 points

smallest asteroid = 100 points

big alien spaceship = 200 points

small alien spaceship = 1000 point

 

 

Credits:

 

Main code: UEZ

Bass UDF: BrettF

Bass DLL: www.un4seen.com

GDI+ font loader code: Yashied

Menu item code: rasim

Sound + sound code modifications: Spiff59

Font: ck! [Freaky Fonts]

GetKeyboardState code: eukalyptus

Atari for the original game concept

AutoIt forum for all the help and the source of knowledge :P

 

Have fun :party:

UEZ

:D

 

 

Change log:

2009-05-16 release of the game AUTOITEROIDS

2009-05-17 thanks to Spiff59 for modification of the sound part -> now the sound is much smoother

2009-05-18 adjusted collision parameters -> now much better collision detection

2009-05-24 added highscore feature and fixed several bugs (RC1)

2009-05-31 pre final version released (only credit intro left)

2009-06-09 some bugs fixed and made some game setting modifications -> game play now smoother; also collision detection adjusted again; credit intro still in building phase :-(

2009-06-11 fixed some wrong game settings and change highscore file format -> now encrypted to avoid highscore manipulation ;-). Old score will be overwritten!

2009-06-13 display of level in GUI title menu was not working properly -> fixed

2009-06-14 released final version but without a credit part (will come later, if I find more time)

2009-06-16 minor: forgot to calculate font size when you change the window resolution (720x480 is optimized for collision detection - other window resolutions may not working properly for collision detection)

2009-06-17 minor: still overlooked font size parameteres and alien spaceship shoot parameters when windows sizes <> 720x480

2009-06-18 minor: some game settings added (will wait a few seconds after all asteroids have been destroyed) and added shadow at Asteroids label in About window

2009-07-01 minor: last update of the game code -> explosion of human spaceship fixed (copy/paste bug), change routine for copy bmp to GUI and added fps display counter

2009-12-21 minor: fixed some small bugs, replaced IsPressed() with WinAPI_GetKeyboardState function (thanks Eukalyptus), added latest Bass.dll, made game play specific modifications and changed code to be compatible with AutoIt v3.3.2.0!

2009-12-29 minor: forgot to undo silly modifications and added faster GDI+ backbuffer technique (thanks to AndyG for the idea)!

2011-04-12 minor: made small modifications, tried some optimizations (it is very hard to remember what I did in the code after a very long time of absence) :)

2011-04-29 minor: GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND") caused About window to look awful and added check for aero to place game graphic window to GUI more precise using _WinAPI_BitBlt()

2011-05-13 minor: cleaned up WinAPI display settings and forgot to undo About window settings.

2011-05-31 minor: speeded up game play by adding bitmaps instead of using one _WinAPI_CreateCompatibleBitmap(). I don't know why this is faster :P

2011-06-09 minor: changed FPS code because old code displayed too high FPS values

2012-07-30 minor: changed drawline function from integer to float to avoid wobbling of asteroids and spaceship

2016-01-14 minor: fixed code to run on AutoIt v3.3.14.2 when no highscore exists and changed GDI+ variable

Edited by UEZ
3 people like this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

REALLY GOOD UEZ!!!

It's just like the real game... movement, sounds, feel-of-control, visuals.

I can even fly through the screen. I used to line up 2 rows of space ships on the pay-to-play game.

I do miss the ability to shoot 4 times in a row though. I used to lay-out a blanket of bullets for the ships.

Can this be added?

Thanks

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

REALLY GOOD UEZ!!!

It's just like the real game.

I can even fly through the screen. I used to line up 2 rows of space ships on the pay-to-play game.

I do miss the ability to shoot 4 times in a row though. Can this be added?

Thanks

8)

Thanks Valuater.

Yes, you are right - the code is not working properly ($amount_of_shoots_max = 4 is already set) :)

I put it also to my to do list :party:

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Well Done UEZ!!, very nice game, I like the realistic movements

Share this post


Link to post
Share on other sites

Well Done UEZ!!, very nice game, I like the realistic movements

Thanks, the human ship movement was a lot easier than the other parts.

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Amazing! 100% Amazing

Thank you so much lots of great work very much to be learned from the source. An amazing demonstration!


AutoIt changed my life.

Share this post


Link to post
Share on other sites

UEZ, good job!

Posted Image

Thanks.

Amazing! 100% Amazing

Thank you so much lots of great work very much to be learned from the source. An amazing demonstration!

Thanks for the feedback - currently I lost the overview over my code :)

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

you should remove bullet limit to make it more authentic


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

you should remove bullet limit to make it more authentic

I wanted to make it 1:1 as much as possible - keep it simple with all its limitations!

I forgot to implement the explosion of the human space which is not an explosion of 10 pixel but breaks in several parts!

I will implement it in the next release.

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

This is absolutely fantastic!

Kudos, UEZ.

I wonder if this would speed collision detection?

;check space ship for border collision
                $z = $border_limes * $object_scale
                If $x < -$z Then $x = $width + $z
                If $x > $width + $z Then $x = -$z
                If $y < -$z Then $y = $height + $z
                If $y > $height + $z Then $y = -$z

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

This is absolutely fantastic!

Kudos, UEZ.

I wonder if this would speed collision detection?

;check space ship for border collision
                    $z = $border_limes * $object_scale
                    If $x < -$z Then $x = $width + $z
                    If $x > $width + $z Then $x = -$z
                    If $y < -$z Then $y = $height + $z
                    If $y > $height + $z Then $y = -$z
Thanks for feedback.

Btw, the check of the border is not the real problem but your are right :)

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Thanks for feedback.

Btw, the check of the border is not the real problem but your are right :)

UEZ

Yes, I noticed that's not the "collision" that I'd like to see happening more often :party:

That area just jumped out at me. I'm good at cleanup, but all this GDI+stuff is greek to me.

How long ago did you start this?

I just have to say, again, I'm flabberghasted. Extremely impressed.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Yes, I noticed that's not the "collision" that I'd like to see happening more often :)

That area just jumped out at me. I'm good at cleanup, but all this GDI+stuff is greek to me.

How long ago did you start this?

I just have to say, again, I'm flabberghasted. Extremely impressed.

I started it approx. 2 weeks ago but I had this in mind a long time ago (just dreamt of it).

Btw, how can I set up the music speed using bass.udf (_BASS_ChannelSetAttribute?)? Because the sound of the alien starship is too slow...

Thanks,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

UEZ this is just totally awesome. Kudos to you my friend. Here comes 5* :)

WBD

Share this post


Link to post
Share on other sites

UEZ this is just totally awesome. Kudos to you my friend. Here comes 5* :party:

WBD

Posted my 5 stars too! :)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Way Cool UEZ! Jumpy for me but looks just like the orig....

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

The smaller files attached below seem to behave better...

Edit: I also tinkered with the definitions for the alien ship sounds to make them looping, then moved the Play() to the random statement that brings the ship out, so it's only called once. Then I put a ChannelStop in your alien_ship_reset routine. So it only starts the sound once when the ship appears and lets it loop until the ship is gone. Seems to sound real smooth with no pauses. I was playing with the control logic for the thump/thump game sounds too, so better make sure I didn;t screw it up. Anyway, it was easier to attach the changes in the whole file than paste them into this post. (Hope you don't mind me playing with your baby, I think it's pretty cool , and I guess I'm bored).

Edit: Deleted attachments to free up some disk space.

Edited by Spiff59

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

The smaller files attached below seem to behave better...

Edit: I also tinkered with the definitions for the alien ship sounds to make them looping, then moved the Play() to the random statement that brings the ship out, so it's only called once. Then I put a ChannelStop in your alien_ship_reset routine. So it only starts the sound once when the ship appears and lets it loop until the ship is gone. Seems to sound real smooth with no pauses. I was playing with the control logic for the thump/thump game sounds too, so better make sure I didn;t screw it up. Anyway, it was easier to attach the changes in the whole file than paste them into this post. (Hope you don't mind me playing with your baby, I think it's pretty cool , and I guess I'm bored).

Thanks Spiff59, the sound is really much smoother. I updated it (1st post)!

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
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

  • Similar Content

    • scintilla4evr
      vPaint - GDI+ image editor
      By scintilla4evr
      Hello everyone!
      As always, I'm proud to present you vPaint. It's an image editor. It uses GDI+ as its drawing library.

      I want to thank to all members of this forum. Without you, this app wouldn't be ever written. Thank you for everything.
       
      Download:
      vPaint 4 image editor
    • Wingens
      Info scraper
      By Wingens
      Hi,
      I don't know if it is possible but I am creating a little program to catalog my game collection.
      It would be awesome if my program could get the boxcover, developer info and game info with the titles I add.
      Does anyone know how to get me started?
    • scintilla4evr
      Motion Graphics UDF
      By scintilla4evr
      Simple UDF for creating animations in GDI+
       
      If you want to see more "experimental" features, go to GitHub.
    • scintilla4evr
      Motion Graphics UDF
      By scintilla4evr
      Hello! I've been working on this UDF for some time, but when I read Seeking "kinetic typography" capability in au3 topic, I decided to share it. This UDF brings some functions for creating animations in GDI+ without worrying about rendering or calculating.

      Features:
      Adding basic shapes (rectangle, ellipse) and text Animating object properties (like position or size) Animatable transformations (translate, rotate, scale) Double-buffering Rendering to a window or GUI control Enjoy!
      Motion Graphics UDF
    • UEZ
      _GDIPlus_BitmapApplyFilter v0.9.5 build 2016-07-14 beta
      By UEZ
      Since I disovered FreeBasic I decided to create a DLL to implement much faster image processing functionality to AutoIt.
      Following functions are implemented yet:
      _GDIPlus_BitmapApplyFilter_Cartoon1 _GDIPlus_BitmapApplyFilter_ColorAccent _GDIPlus_BitmapApplyFilter_Convolution_AnotherBlur _GDIPlus_BitmapApplyFilter_Convolution_BoxBlur _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection1 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection2 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection3 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection4 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection5 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection6 _GDIPlus_BitmapApplyFilter_Convolution_Emboss1 _GDIPlus_BitmapApplyFilter_Convolution_Emboss45Degree _GDIPlus_BitmapApplyFilter_Convolution_EmbossTopLeftBottomRight _GDIPlus_BitmapApplyFilter_Convolution_Gaussian3x3 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_1 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_2 _GDIPlus_BitmapApplyFilter_Convolution_GaussianBlur _GDIPlus_BitmapApplyFilter_Convolution_IntenseEmboss _GDIPlus_BitmapApplyFilter_Convolution_Kirsch _GDIPlus_BitmapApplyFilter_Convolution_Laplace1 _GDIPlus_BitmapApplyFilter_Convolution_Laplace2 _GDIPlus_BitmapApplyFilter_Convolution_Laplace3 _GDIPlus_BitmapApplyFilter_Convolution_LaplacianOfGaussian _GDIPlus_BitmapApplyFilter_Convolution_ManualMatrix _GDIPlus_BitmapApplyFilter_Convolution_MotionBlur _GDIPlus_BitmapApplyFilter_Convolution_Outline3x3 _GDIPlus_BitmapApplyFilter_Convolution_Prewitt _GDIPlus_BitmapApplyFilter_Convolution_Sharpen1 _GDIPlus_BitmapApplyFilter_Convolution_Sharpen2 _GDIPlus_BitmapApplyFilter_Convolution_Sobel _GDIPlus_BitmapApplyFilter_Convolution_SovelVsPrewitt _GDIPlus_BitmapApplyFilter_Convolution_TriangleBlur _GDIPlus_BitmapApplyFilter_Convolution_Unsharp _GDIPlus_BitmapApplyFilter_Convolution_Unsharp5x5 _GDIPlus_BitmapApplyFilter_Dilatation _GDIPlus_BitmapApplyFilter_DistortionBlur _GDIPlus_BitmapApplyFilter_Edges _GDIPlus_BitmapApplyFilter_Erosion _GDIPlus_BitmapApplyFilter_FishEye _GDIPlus_BitmapApplyFilter_Jitter _GDIPlus_BitmapApplyFilter_Kuwahara _GDIPlus_BitmapApplyFilter_Linellism _GDIPlus_BitmapApplyFilter_Median _GDIPlus_BitmapApplyFilter_Median2 _GDIPlus_BitmapApplyFilter_OilPainting _GDIPlus_BitmapApplyFilter_PenSketch _GDIPlus_BitmapApplyFilter_PenSketch2 _GDIPlus_BitmapApplyFilter_Pixelate _GDIPlus_BitmapApplyFilter_Pointillism _GDIPlus_BitmapApplyFilter_RadialBlur _GDIPlus_BitmapApplyFilter_Raster _GDIPlus_BitmapApplyFilter_Swirl _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour _GDIPlus_BitmapApplyFilter_TiltShift _GDIPlus_BitmapApplyFilter_TimeWarp _GDIPlus_BitmapApplyFilter_Wave _GDIPlus_BitmapApplyFilter_XRay  
      Since I am absolutely a newbie in FreeBasic, the DLL may contain errors.  Please report any bug.
       
      To do:
      add function headers with descriptions speed-up FB code -> partly done add more filters -> ongoing  
      Credits to:
      Jakub Szymanowski rdc Dewald Esterhuizen Santhosh G_  Christian Graus www.gutgames.com  
      Have fun.
       
      Download link: 

       
      You can compare the speed with AutoIt version:
      #AutoIt3Wrapper_Version=b #include <Array.au3> #include <GDIPlus.au3> Global $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Global Const $hGUI = GUICreate("GDI+ Image Filters", $iW * 2, $iH) Global $fProg = 0, $iEnd = $iW * $iH - 1 AdlibRegister("Progress", 490) Global $t = TimerInit() Global Const $hGDIBitmap = _GDIPlus_BitmapApplyFilter_Median($hImage, 4) ConsoleWrite(Round(TimerDiff($t) / 1000, 2) & " s / " & Round(TimerDiff($t) / 60000, 2) & " min" & @CRLF) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1) Global Const $iPic_o = GUICtrlCreatePic("", $iW, 0, $iW - 1, $iH - 1) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) Global Const $hGDIBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_o, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap2)) GUISetState() AdlibUnRegister("Progress") ToolTip("") Do Until GUIGetMsg() = -3 _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap2) _GDIPlus_Shutdown() Exit Func Progress() ToolTip(Int($fProg / $iEnd * 100) & " % / " & Round(TimerDiff($t) / 60000, 2) & " min", MouseGetPos(0) + 30, MouseGetPos(1) + 30) EndFunc #Region Symmetric Nearest Neighbour Func _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour($hImage, $fRadius = 2, $bGDI = True) ;no alpha channel implemented yet Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iRowOffset, $iX, $iY, $c, $k, $sumR, $sumG, $sumB, $iCount, $xx, $yy, $iR, $iG, $iB, $iR1, $iG1, $iB1, $iR2, $iG2, $iB2, $x, $y For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW For $iX = 0 To $iW - 1 $sumR = 0 $sumG = 0 $sumB = 0 $iCount = 0 $c = DllStructGetData($tPixel, 1, $iRowOffset + $iX) $iR = BitShift(BitAND(0x00FF0000, $c), 16) $iG = BitShift(BitAND(0x0000FF00, $c), 8) $iB = BitAND(0x000000FF, $c) For $yy = -$fRadius To $fRadius For $xx = -$fRadius To $fRadius $k = $iX + $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = $iY + $yy $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR1 = BitShift(BitAND(0x00FF0000, $c), 16) $iG1 = BitShift(BitAND(0x0000FF00, $c), 8) $iB1 = BitAND(0x000000FF, $c) $k = $iX - $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = ($iY - $yy) $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR2 = BitShift(BitAND(0x00FF0000, $c), 16) $iG2 = BitShift(BitAND(0x0000FF00, $c), 8) $iB2 = BitAND(0x000000FF, $c) If __DeltaE($iR, $iG, $iB, $iR1, $iG1, $iB1) < __DeltaE($iR, $iG, $iB, $iR2, $iG2, $iB2) Then $sumR += $iR1 $sumG += $iG1 $sumB += $iB1 Else $sumR += $iR2 $sumG += $iG2 $sumB += $iB2 EndIf $iCount += 1 Next Next DllStructSetData($tPixel_Dest, 1, 0xFF000000 + Int($sumR / $iCount) * 0x10000 + Int($sumG / $iCount) * 0x100 + Int($sumB / $iCount), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_SNN" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __DeltaE($iR1, $iG1, $iB1, $iR2, $iG2, $iB2) Return Sqrt(($iR1 - $iR2) * ($iR1 - $iR2) + ($iG1 - $iG2) * ($iG1 - $iG2) + ($iB1 - $iB2) * ($iB1 - $iB2)) EndFunc #EndRegion #Region Jitter Func _GDIPlus_BitmapApplyFilter_Jitter($hImage, $iAmount = 20, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset, $fNX, $fNY For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $fNX = $iX + Int((Random() - 0.5) * $iAmount) $fNX = $fNX < 1 ? 1 : $fNX > $iW - 1 ? $iW - 1 : $fNX $fNY = ($iY + Int((Random() - 0.5) * $iAmount)) $fNY = $fNY < 1 ? 1 : $fNY > $iH - 1 ? $iH - 1 : $fNY $fNY *= $iW DllStructSetData($tPixel_Dest, 1, DllStructGetData($tPixel, 1, $fNY + $fNX), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Jitter" & $iAmount & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc #EndRegion #Region Median Func _GDIPlus_BitmapApplyFilter_Median($hImage, $fRadius = 3, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 DllStructSetData($tPixel_Dest, 1, __Median_Value($iX, $iY, $fRadius, $tPixel, $iW, $iH), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Median" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __Median_Value($iPosX, $iPosY, $fRadius, $tPixel, $iW, $iH) Local $iX, $iY, $aColors[1000], $iColors = 0, $iSize = $iW * $iH - 1, $iOff, $e For $iX = $iPosX - $fRadius To $iPosX + $fRadius For $iY = $iPosY - $fRadius To $iPosY + $fRadius $iOff = 1 + $iY * $iW + $iX $aColors[$iColors] = DllStructGetData($tPixel, 1, $iOff < 1 ? 1 : $iOff > $iSize ? $iSize : $iOff) $iColors += 1 Next Next ReDim $aColors[$iColors] ;~ _ArraySort($aColors, 0) $e = $iColors - 1 __ArrayQuickSort1D($aColors, 0, $e) Local $iMid = Floor($iColors / 2), $iMedian If BitAND($iColors, 1) Then $iMedian = Int($aColors[$iMid + 1]) Else $iMedian = Int(($aColors[$iMid] + $aColors[$iMid + 1]) / 2) EndIf Return $iMedian EndFunc #EndRegion