andrewseul Posted March 19, 2011 Posted March 19, 2011 (edited) Thank You. Edited May 26, 2016 by andrewseul
UEZ Posted March 19, 2011 Posted March 19, 2011 (edited) Here an example made by AndyG:expandcollapse popup;Code by AndyG #include <AssembleIt.au3> #include <GDIPlus.au3> Global $Scan, $iWidth, $iHeight, $colour ;declare variables in Assemblerfunction Func _colour_rasterize() _("use32") ;32bit-Mode _("mov esi," & $Scan) ;Startadress Bitmapdata (Pixel) _("mov ecx," & $iWidth * $iHeight) ;number of Pixels _("mov edi," & $colour) ;... ;width even or odd? _("mov eax," & $iWidth);width into register _("bt eax,0") ;bit test bitnumber and store the result into Carry-Flag CF _("jc _odd") ;if CF=1 (bit0_of_eax=1) then jump _odd ;an even number of pixels in a line is not so easy, because we ;need a counter (EBX) to find out if we have to paint up the first pixel in the line ;or the second one! _("mov ebx,1") ;counter pixel_per_line _("_loop:") ;loop until ecx=0 (whole image rasterized) _("cmp ebx,eax") ;is end of line reached? _("jae _next") ;end of line reached, then _next: _("mov dword[esi],edi") ;else paint pixel _("add esi,8") ;every 2. pixel in memory 8 Byte = 2 pixel AARRGGBB _("add ebx,2") ;increment counter _("sub ecx,2") ;decrement # of remaining pixel _("ja _loop") ;until ecx=0, jump to _loop: _("ret ") ;end program _("_next: ") ;end of line reached _("bt ebx,0") ;last pixel# odd? _("jnc _even_line") ;if even, jump _even_line _("mov ebx,0") ;counter, every 2nd line _("add esi,4") ;next address of pixel in memory _("sub ecx,1") ;remaing # of pixel _("ja _loop") ;loop until ecx=0 (whole image rasterized) _("ret") ;end program _("_even_line:") ;paint first pixel in line _("mov ebx,1") ; _("sub esi,4") ;we are one pixel too far!... _("add ecx,1") ;...so paint the pixel before the actual one _("jmp _loop") ;fill line painting every 2nd pixel ;odd number of pixels in a line, very easy, because every 2nd ;pixel is colored to rasterize the image _("_odd:") _("_loop1:") ;until ecx=0 _("mov dword[esi],edi") ;colour pixel _("add esi,8") ;every 2. pixel _("sub ecx,2") ;decrement number of remaining pixel _("ja _loop1") ;loop until ecx=0 (whole image rasterized) _("ret ") ;end program EndFunc ;==>_colour_rasterize _GDIPlus_Startup() $file = FileOpenDialog("Select 24 or 32 Bpp Image", @ScriptDir, "Images (*.jpg;*.bmp)", 1 + 2) If @error Then Exit $hBitmap = _GDIPlus_BitmapCreateFromFile($file) Local $iWidth, $iHeight, $hBitmapData, $Scan, $Stride, $tPixelData, $pPixelStruct $iWidth = _GDIPlus_ImageGetWidth($hBitmap) $iHeight = _GDIPlus_ImageGetHeight($hBitmap) $hBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32RGB) $Scan = DllStructGetData($hBitmapData, "Scan0") ;Startadress of Bitmapdata $colour = 0x7FF17FFF ;pink $ret = _AssembleIt("ptr", "_colour_rasterize") ;Run the Assemblercode _GDIPlus_BitmapUnlockBits($hBitmap, $hBitmapData) FileDelete(@ScriptDir & "\raster_pink.bmp") _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\raster_pink.bmp") _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_ShutDown() ShellExecute(@ScriptDir & "\raster_pink.bmp") FasmExit($Fasm) ;FASM remove from memoryYou need to run it properly!The opcode will be printed to console.Br,UEZ Edited March 19, 2011 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
andrewseul Posted March 19, 2011 Author Posted March 19, 2011 I tried to use your suggestion but when I run it, Autoit is stop respoding anymore and is crashing. I have windows 7 x64. Latest build of Autoit.
UEZ Posted March 19, 2011 Posted March 19, 2011 (edited) Tested also with Win7 x64 and latest AutoIt version but it is working properly for me whereas I don't use native x64, only x86 (during setup of AutoIt you can select how AutoIt should handle the code).Maybe #AutoIt3Wrapper_UseX64=n might help.Br,UEZ Edited March 19, 2011 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
trancexx Posted March 19, 2011 Posted March 19, 2011 Anyway, jump dword is E9. In your case it's:0xE900343213 But the question is what's the question? ♡♡♡ . eMyvnE
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now