Jump to content

Search the Community

Showing results for tags 'art'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. An "improper" "unusual" use of Excel the script allows the creation of artistic images by simply coloring the background of the individual cells of the Excel workbook. Although definitely useless ... I find it quite funny though have a good time many thanks to @UEZ , @Malkey , @water p.s. I think the pixelite + color to array process can be simplified, but I used the two ready-made functions provided by UEZ and Malkey. I thank both of you (credits and links in listing) p.p.s. strange behaviour: while excell is filling cells, if you move the mouse pointer off the excell window, the fill speed increases ... (?) ; =============================================================================================================================== ; Name ..........: Excel in art ; Description ...: This script allows the creation of artistic images in Excel from a choosed picture. ; The picture is done by simply coloring the background of the individual cells of an Excel workbook. ; Although definitely useless, I find it quite funny though ; ; Return values .: An artistic image in an Excel workbook ; Author ........: Addiego Gianni (chimp) ; Modified ......: ; Remarks .......: Many thanks to UEZ, Malkey and Water ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== #include <GDIPlus.au3> #include <Excel.au3> _PixelsToCells(50) ; <-- Parameter 50 is the cumber of horizontal Excel cells to be filled MsgBox(64, "All done", "Excel art is ready") Func _PixelsToCells($iHcells = 50) ; Check application object Local $oExcel = _Excel_Open() If Not IsObj($oExcel) Then MsgBox(16, "Error", "Sorry, You need to have 'Excel' intalled") ; Choose Image File Local $sPath = FileOpenDialog("Choose Image File", @ScriptDir & "", "Images (*.gif;*.png;*.jpg;*.bmp)| All (*.*)") If $sPath = '' Then Exit MsgBox(16, "Error", "Sorry, no image was chosen") ; Create a new Excel workbook $oWorkbook = _Excel_BookNew($oExcel, 1) ; initialize GDI+ _GDIPlus_Startup() Local $hBmp = _GDIPlus_BitmapCreateFromFile($sPath) Local $iWidth = _GDIPlus_ImageGetWidth($hBmp) ; get image width ; Local $iHeight = _GDIPlus_ImageGetHeight($hBmp) ; not needed here Local $iStep = $iWidth / $iHcells ; calculate the pixelation factor Local $hBitmap_new = _GDIPlus_PixelateBitmap($hBmp, $iStep) ; pixelate the image Local $aPixelColors = _FileImageToArray($hBitmap_new) ; get pixel colors ; reduce Excel columns width Local $xx = 1, $yy = 1 For $iCol = 0 To UBound($aPixelColors, 2) - 1 Step $iStep $oWorkbook.Sheets(1).Columns($xx).ColumnWidth = 1 $xx += 1 Next ; reduce Excel rows height For $iRow = 0 To UBound($aPixelColors) - 1 Step $iStep $oWorkbook.Sheets(1).Rows($yy).RowHeight = 9 $yy += 1 Next $xx = 1 $yy = 1 For $iRow = 0 To UBound($aPixelColors) - 1 Step $iStep For $iCol = 0 To UBound($aPixelColors, 2) - 1 Step $iStep $oWorkbook.Sheets(1).Range(_Excel_ColumnToLetter($xx) & $yy).Interior.Color = Number("0x" & $aPixelColors[$iRow][$iCol]) $xx += 1 Next $yy += 1 $xx = 1 Next _GDIPlus_BitmapDispose($hBmp) _GDIPlus_Shutdown() EndFunc ;==>_PixelsToCells ; by UEZ ; https://www.autoitscript.com/forum/topic/167707-imagepixelate/?do=findComment&comment=1227509 Func _GDIPlus_PixelateBitmap($hBitmap, $iPixelate, $bSmooth = 1) Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $iNewW = Round($iWidth / $iPixelate, 0), $iNewH = Round($iHeight / $iPixelate, 0) Local $hBitmap_scaled = _GDIPlus_BitmapCreateFromScan0($iNewW, $iNewH) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_scaled) Local $iInterpolation = 5 If $bSmooth Then $iInterpolation = $GDIP_INTERPOLATIONMODE_BILINEAR _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $iInterpolation) _GDIPlus_GraphicsDrawImageRect($hCtxt, $hBitmap, 0, 0, $iNewW, $iNewH) _GDIPlus_GraphicsDispose($hCtxt) Local $hBitmap_pixelated = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_pixelated) _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $GDIP_INTERPOLATIONMODE_NearestNeighbor) _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBitmap_scaled, 0, 0, $iNewW, $iNewH, -$iPixelate, -$iPixelate, $iWidth + 2 * $iPixelate, $iHeight + 2 * $iPixelate) _GDIPlus_GraphicsDispose($hCtxt) Return $hBitmap_pixelated EndFunc ;==>_GDIPlus_PixelateBitmap ; by Malkey ; https://www.autoitscript.com/forum/topic/112540-is-there-a-function-for-reading-images-into-2d-arrays/?do=findComment&comment=788472 Func _FileImageToArray($hImage) Local $Reslt, $stride, $format, $Scan0, $iIW, $iIH ; , $hImage Local $v_Buffer, $width, $height ; _GDIPlus_Startup() ; $hImage = _GDIPlus_ImageLoadFromFile($sFileName) $iIW = _GDIPlus_ImageGetWidth($hImage) $iIH = _GDIPlus_ImageGetHeight($hImage) ProgressOn("Progress Bar", "Filling a " & $iIW & " x " & $iIH & " size array.", "0 percent") $Reslt = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iIW, $iIH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") Local $aArray[$height][$width] For $j = 0 To $iIH - 1 For $i = 0 To $iIW - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = StringRegExpReplace(Hex(DllStructGetData($v_Buffer, 1), 6), "(.{2})(.{2})(.{2})", "\3\2\1") ; To RGB format Next ProgressSet(Int(100 * $j / ($iIH)), Int(100 * $j / ($iIH)) & " percent") Next _GDIPlus_BitmapUnlockBits($hImage, $Reslt) ProgressOff() _GDIPlus_ImageDispose($hImage) Return $aArray EndFunc ;==>_FileImageToArray
  2. After reading this page, (http://www.drububu.com/illustration/tsp/index.html) I was curious and I put together this script. it is not a "stand alone" script, as it uses some third parties programs*, but in few steps it acomplish the conversion to the TSP art. The generated images are quite nice, but you have to try more attempts to find the right combinations of parameters for different source images. Best results can easily obtained with schematic black and wite images. Drag and drop for example something like in this link. Also, set the "Variable thickness line" option and try with the image at this link for another example: (https://images.fineartamerica.com/images/artworkimages/mediumlarge/1/david-michelangelo-murphy-elliott.jpg) Since used programs generate also some temporay files, please save this script and the dependencies into a single folder so to avoid the scattering of files around and also allowing the main script to find the needed programs. Example of an TSP art generated with this script and related programs (the image on the left is converted in the image on the right) just drag and drop images on the GUI of the script and all is done automatically. * Here are the links to download the needed "dependencies": ( just put all the stuff in a single folder along with the script.) voronoi.exe http://www.drububu.com/illustration/tsp/voronoi.zip stippler.dll also contained in the above archive concorde.exe http://www.math.uwaterloo.ca/tsp/concorde/downloads/codes/cygwin/concorde.exe.gz this program needs the cygwin dll (a very nice one) (I've used 7zip to open this archive) cygwin1.dll https://cygwin.com/snapshots/ get one x86 cygwin1-xxxxxxxx.dll.xz (only dll) svg_extract.exe http://www.drububu.com/illustration/tsp/svg_extract.zip tsp2svg.exe http://www.drububu.com/illustration/tsp/tsp2svg.zip here the script: ; TSP Art generator #include <FileConstants.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <GDIPlus.au3> If Not _CheckDependencies() Then Exit ; can't run without dependencies. Global $bDropped, $sFile, $bDropAllowed = True ; create a blank file, or empty it if it's already created Global $hTail, $sLogFile = FileGetShortName(@ScriptDir & "\LogFile.txt") _GDIPlus_Startup() ; just for image format conversion to PNG (if needed) $Form1 = GUICreate("TSP art generator", 500, 650, -1, -1, -1, $WS_EX_ACCEPTFILES) ; --- options $Combo1 = GUICtrlCreateCombo("", 350, 505, 60, 25) GUICtrlCreateLabel("Sampling points", 415, 510, 80, 25) GUICtrlSetData($Combo1, "1000|2000|4000|6000|8000|10000|20000|40000|60000", "4000") ; some sampling rate $Checkbox1 = GUICtrlCreateCheckbox("Variable thickness line", 350, 535, 145, 25) $Checkbox2 = GUICtrlCreateCheckbox("Color (voronoi only)", 350, 565, 145, 25) ; --- Log viewer Global $hLog = GUICtrlCreateEdit("", 5, 500, 340, 145, BitOR($WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_MULTILINE, $ES_READONLY)) ; log viewer GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetFont(-1, 9, -1, -1, "Courier New") ; following is a transparent control over the browser control ; purpose is to avoid that the drop event is captured by the browser control $hGlass = GUICtrlCreateLabel("", 0, 0, 500, 650) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; This is like a glass over the following underlying browser Control GUICtrlSetCursor(-1, 2) ; Cursor is an arrow (instead of the default I-beam) ; --- Embed a browser control Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 5, 5, 490, 490) $oIE.navigate("about:blank") AutoItSetOption("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") GUISetState(@SW_SHOW, $Form1) _LogPrint(@CRLF & _ "Hello," & @CRLF & _ "Drag and dropping images here above," & @CRLF & _ "will be converted into a TSP Art." & @CRLF & _ "have fun...") ; --- Main loop While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE _Exit() Case $bDropped = True $bDropped = False $bDropAllowed = False ; Drop not allowed while generating _Generate_PST_Art() $bDropAllowed = True EndSelect WEnd ; --- Call externa programs the right sequence Func _Generate_PST_Art() _EmptyLog() ; empty the temporary log file _checkFileFormat($sFile) ; if dropped image isn't a PNG convert it to PNG _ShowInBrowser($sFile) ; show dropped image in the browser control ; step 1) Transform PNG image into a voronoi svg image ; ============================================================================ If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; variable thickness line? $sOptions = "" Else $sOptions = " -f " ; fixed radus EndIf If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then ; color points for voronoi? $sOptions = " -c " & $sOptions EndIf ; _call_External_Program(".\voronoi.exe " & $sOptions & "-s " & GUICtrlRead($Combo1) & " -n -I " & $sFile & " -O out.svg", True) _call_External_Program(FileGetShortName(@ScriptDir & '\voronoi.exe') & $sOptions & ' -s ' & GUICtrlRead($Combo1) & ' -n -I ' & $sFile & ' -O out.svg', True) _ShowInBrowser(FileGetShortName(@ScriptDir & "\out.svg")) ; show generated voronoi image in the browser control ; ; step 2) Extract points from the voronoi svg image and save to positions.tsp file ; for later input by the concorde TSP solver ; ============================================================================ _call_External_Program(FileGetShortName(@ScriptDir & '\svg_extract.exe') & " out.svg") _LogPrint("... going to next step ...") ; ; step 3) Resolve the Traveling Salesman Problem using the very good ; concorde.exe program (it needs the presence of the cygwin1.dll to work) ; ============================================================================ _call_External_Program(FileGetShortName(@ScriptDir & "\concorde.exe") & " -V -o tour.cyc positions.tsp", True) _LogPrint("... going to next step ...") ; ; step 3a) some adjustments to the tour.cyc file generated by concorde.exe ; ============================================================================ $hfile = FileOpen(FileGetShortName(@ScriptDir & '\tour.cyc')) Local $sContent = FileRead($hfile) FileClose($hfile) FileDelete(FileGetShortName(@ScriptDir & '\tour.cyc')) $sContent = StringReplace($sContent, Chr(0x20), Chr(0x0A)) _LogPrint("Replaced 0x20 with 0x0A " & @extended & " times.") $sContent = StringReplace($sContent, Chr(0x0A) & Chr(0x0A), Chr(0x0A)) _LogPrint("Replaced 0x0A 0x0A with 0x0A " & @extended & " times." & @CRLF) Local $x = StringInStr($sContent, Chr(0x0A)) ; first 0A $sContent = StringMid($sContent, $x + 1) ; remove first data (it's the number of points, not a point) $hfile = FileOpen(FileGetShortName(@ScriptDir & '\tour.cyc'), $FO_OVERWRITE + $FO_BINARY) FileWrite($hfile, $sContent) ; save adjusted data FileFlush($hfile) FileClose($hfile) ; ; step 4) "merge" data from out.svg and tour.cyc into the final tsp_art.svg file ; ============================================================================ If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $sOptions = " +w" ; variable thickness line Else $sOptions = "" ; fixed thickness line EndIf $sOptions = FileGetShortName(@ScriptDir & "\tsp2svg.exe") & " out.svg tour.cyc" & $sOptions _call_External_Program($sOptions) _ShowInBrowser(FileGetShortName(@ScriptDir & "\tsp_art.svg")) _LogPrint(@CRLF & _ "+-----------------------------------+" & @CRLF & _ "| End of conversion --> tsp_art.svg |" & @CRLF & _ "+-----------------------------------+" & @CRLF) EndFunc ;==>_Generate_PST_Art ; === Functions Func _call_External_Program($sCommand, $bVerbose = False) Local $sLine If $bVerbose = True Then $sCommand = @ComSpec & " /c " & $sCommand & ">>" & $sLogFile & " 2>>&1" EndIf Local $hPid = Run($sCommand, ".", @SW_HIDE) If Not $hPid Then _LogPrint("Error on run external program" & @CRLF) Return SetError(1) EndIf Do If $bVerbose Then $sLine = FileReadLine($hTail) If Not @error Then _LogPrint($sLine) EndIf EndIf Until Not ProcessExists($hPid) If $bVerbose Then $sLine = "..." ; "Task execution terminated ...." Do _LogPrint($sLine) $sLine = FileReadLine($hTail) Until @error EndIf EndFunc ;==>_call_External_Program Func _LogPrint($sLine) If StringLen(GUICtrlRead($hLog)) > 25000 Then ; Max Len of a CtrlBox is 30000 char _GUICtrlEdit_SetText($hLog, StringRight(GUICtrlRead($hLog), 20000)) ; short the content of CtrlBox to 20000 char EndIf _GUICtrlEdit_AppendText($hLog, $sLine & @CRLF) EndFunc ;==>_LogPrint Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) If $bDropAllowed Then Local $sExt = ".bmp|.png|.jpg|.gif" ; img drop filtering thanks to @UEZ Local $aFileList = _WinAPI_DragQueryFileEx($wParam) If Not @error Then For $i = 1 To $aFileList[0] If StringInStr($sExt, StringRegExpReplace($aFileList[$i], ".*(\.+)", "$1")) Then $bDropped = True $sFile = FileGetShortName($aFileList[$i]) ExitLoop EndIf Next Else _LogPrint("Error on drop" & @CRLF) EndIf _WinAPI_DragFinish($wParam) _LogPrint("Droped: " & $sFile & @CRLF) Return 0 EndIf EndFunc ;==>WM_DROPFILES Func _ShowInBrowser($sImg) ; setup Javascript engine with also embeded the "entity" library If StringRight($sImg, 3) = "svg" Then Else EndIf ; *** create a minimal 'html' page listing for the browser control Local $sHTML = "<HTML><HEAD>" & @CRLF & _ "<meta http-equiv=""X-UA-Compatible"" content=""IE=edge"" />" & @CRLF & _ "</HEAD>" & @CRLF & _ "<body>" & @CRLF & _ '<img src="' & $sImg & '" style="width:100%; height:100%;" />' & @CRLF & _ "</body>" & @CRLF & _ "</HTML>" & @CRLF ; html closing tags ; *** end of html page listing ; _LogPrint(">_" & @CRLF) $oIE.navigate('about:blank') While Not String($oIE.readyState) = 'complete' ; wait for about:blank Sleep(100) WEnd $oIE.document.Write($sHTML) ; inject lising directly to the HTML document: $oIE.document.close() ; close the write stream Sleep(1000) $oIE.document.execCommand("Refresh") EndFunc ;==>_ShowInBrowser Func _checkFileFormat($sFile) Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) Local $aFormat = _GDIPlus_ImageGetRawFormat($hImage) If $aFormat[1] <> "PNG" Then _ConvertToPNG($hImage) _GDIPlus_ImageDispose($hImage) EndFunc ;==>_checkFileFormat Func _ConvertToPNG(ByRef $hImage) Local $CLSID = _GDIPlus_EncodersGetCLSID('PNG') $sFile = FileGetShortName(@ScriptDir & "\Input.png") _GDIPlus_ImageSaveToFileEx($hImage, $sFile, $CLSID) EndFunc ;==>_ConvertToPNG Func _EmptyLog() FileClose($hTail) $hTail = FileOpen($sLogFile, $FO_OVERWRITE) FileWrite($hTail, "Start log: " & @YEAR & '/' & @MON & '/' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & @CRLF) FileFlush($hTail) FileClose($hTail) $hTail = FileOpen($sLogFile) ; read only EndFunc ;==>_EmptyLog Func _CheckDependencies() Local $iDependencie = 0 $iDependencie += FileExists(@ScriptDir & "\voronoi.exe") ; http://www.drububu.com/illustration/tsp/voronoi.zip $iDependencie += FileExists(@ScriptDir & "\stippler.dll") ; " also contained in the above archive $iDependencie += FileExists(@ScriptDir & "\concorde.exe") ; http://www.math.uwaterloo.ca/tsp/concorde/downloads/codes/cygwin/concorde.exe.gz $iDependencie += FileExists(@ScriptDir & "\cygwin1.dll") ; get one from here https://cygwin.com/snapshots/ get cygwin1-xxxxxxxxx.dll.xz $iDependencie += FileExists(@ScriptDir & "\svg_extract.exe") ; http://www.drububu.com/illustration/tsp/svg_extract.zip $iDependencie += FileExists(@ScriptDir & "\tsp2svg.exe") ; http://www.drububu.com/illustration/tsp/tsp2svg.zip Return $iDependencie = 6 EndFunc ;==>_CheckDependencies Func _Exit() _GDIPlus_Shutdown() FileClose($hTail) AutoItSetOption("GUIOnEventMode", 0) GUIRegisterMsg($WM_DROPFILES, "") Exit EndFunc ;==>_Exit
  3. Bitmap2AscII use Lucida Console font with a size set to 8, so Windows 8/8.1 users need to change their notepad font and size for get a correct display. Image Rescale slider is only available when saving as image. A click on the "PreviewEdit" open AscII string in Notepad. You can save as Text, Html or Image (add the extension you want) Each setting change is immediately applied. Downloads available in the download section Hope you like it !
×
×
  • Create New...