Shanheavel Posted December 9, 2010 Share Posted December 9, 2010 (edited) Hello!Is possible to make font from pic,bmp or jpg and color it with autoit?For example: Edited December 9, 2010 by Adrian777 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted December 9, 2010 Share Posted December 9, 2010 Sure, why not. Here's a example using SDL. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
iamtheky Posted December 9, 2010 Share Posted December 9, 2010 This will save all of a single color of a bitmap to a text file - set the .bmp - and the save file name and path, and set the _findcolor color. expandcollapse popup#include <Array.au3> Global $IMAGE = "IMAGENAME.bmp" Global $SAVEFILE = "c:\SAVE_FILE_NAME.txt" Dim $RED Dim $ALL[1] Dim $Columns[1] $loading = _PicToArray($IMAGE, 400) _findcolor ($loading, "FF0000") _save($ALL , $SAVEFILE) Func _findcolor ($SrcArray, $Color) For $i = 0 TO Ubound ($SrcArray) - 1 $RED = _ArrayFindAll ($SrcArray , $Color , 0 , 0 ,0 ,1, $i) For $k = 0 to ubound ($RED) - 1 _ArrayAdd ($Columns , $i) Next _ArrayConcatenate ($ALL , $RED) Next EndFunc Func _PicToArray($pic, $size) Dim $BArray[$size][$size] SplashImageOn("", $pic , $size, $size, 0, 0, 1) For $B = 0 To ubound ($BArray, 1) - 1 For $C = 0 To ubound ($BArray, 2) - 1 $BArray[$B][$C] = "0x" & Hex(PixelGetColor($B + 1, $C + 1), 6) Next Next splashoff () Return $BArray EndFunc Func _save($SrcArray , $FileName) $pixFile = fileopen ($FileName , 2) For $i = 1 to ubound ($All) - 1 filewriteline ($pixFile , $Columns[$i]) filewriteline ($pixFile , $ALL[$i]) Next FileClose ($pixFile) EndFunc This will draw that text file and color it. expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <file.au3> $fromFile1 = _load("c:\SAVED_FILE.txt") $TOP = ubound ($fromfile1) / 2 ReDim $fromfile1[$TOP][2] _DrawPicfromArray ($fromfile1) Func _DrawPicfromArray($Srcarray) $MAX = ubound($SrcArray) $Half = $MAX / 2 While 1 Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) Local $D, $E For $j = 0 To $MAX $i = random (0, $MAX) $D = $SrcArray[$i][0] $E = $SrcArray[$i][1] _HPSleep(100,0) _PixelSetColor($E , $D , 0xFF0000) next For $z = 0 To $Half $D = $SrcArray[$z][0] $E = $SrcArray[$z][1] _PixelSetColor($E, $D ,0x0000FF) _HPSleep(100,0) Next For $x = $Half To $MAX - 1 $D = $SrcArray[$x][0] $E = $SrcArray[$x][1] _PixelSetColor($E , $D , 0x00FF00) _HPSleep(100,0) Next For $j = 0 to $Max $i = random (0, $MAX) $D = $SrcArray[$i][0] $E = $SrcArray[$i][1] _HPSleep(100,0) _PixelSetColor($E, $D, 0x000000) Next DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0]) WEnd EndFunc ; Modified from http://www.autoitscript.com/forum/index.php?showtopic=7315&view=findpost&p=178779 Func _PixelSetColor($XCoord, $YCoord, $Color) Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) If Not IsArray($dc) Then Return -1 DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _ "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format. DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0]) EndFunc ;==>_PixelSetColor Func _HPSleep($iSleep, $fMs = 1) ; default is milliseconds, otherwise microseconds (1 ms = 1000 µs) If $fMs Then $iSleep *= 1000 ; convert to ms DllCall("ntdll.dll", "dword", "NtDelayExecution", "int", 0, "int64*", -10 * $iSleep) EndFunc Func _load($file) $Num = _FileCountLines ($file) $J = $Num $H = $Num / 2 Dim $BArray [$J][2] $file = fileopen ($file , 0) for $K = 0 to $H - 1 $line = filereadline ($file) $BArray[$K][0] = $line $line = filereadline ($file) $BArray[$K][1] = $line Next FileClose ($file) Return $BArray EndFunc Attached is an example of the Saved File.LOADING.txt ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Shanheavel Posted December 9, 2010 Author Share Posted December 9, 2010 Thanks for help! Link to comment Share on other sites More sharing options...
UEZ Posted December 9, 2010 Share Posted December 9, 2010 (edited) This is another method:expandcollapse popup;coded by UEZ 2010-12-09 #include <EditConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $width = 608 $heigth = 160 $hGUI = GUICreate("Bitmap Font to Screen by UEZ 2010", $width, $heigth, -1, -1) $bgc = "B0B0F0" GUISetBkColor("0x" & $bgc, $hGUI) $Input = GUICtrlCreateInput("", 80, 8, 513, 21) $Label = GUICtrlCreateLabel("Enter any text:", 8, 8, 72, 17, $SS_CENTERIMAGE) GUISetState(@SW_SHOW) _GDIPlus_Startup() $factor1 = 0.666667 $factor2 = 1 - $factor1 $gfx_w = $width $gfx_h = $heigth * $factor1 $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($gfx_w, $gfx_h, $hGraphic) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) If Not FileExists("fontjs.png") Then Extract_Bitmap() $hImage = _GDIPlus_ImageLoadFromFile("fontjs.png") _GDIPlus_GraphicsSetInterpolationMode($hBackbuffer, 5) _GDIPlus_GraphicsClear($hBackbuffer, 0xFFB0B0F0) GUIRegisterMsg($WM_COMMAND, 'Print_Bitmap_Font') While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndSwitch WEnd Func Print_Bitmap_Font($hWnd, $Msg, $wParam, $lParam) Local $fw = 16, $fh = 16, $size = 1, $dx = 10 * $size Local $chk $chk = BitAND($wParam, 0x0000FFFF) Switch $chk Case $Input $inp = GUICtrlRead($Input) $inp_len = StringLen($inp) If $inp_len < Ceiling($width / $dx - 2) Then $aInp = StringSplit($inp, "", 2) _GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bgc) For $i = 0 To $inp_len - 1 $x = Mod(Asc($aInp[$i])-32, 32) $y = Floor((Asc($aInp[$i])-32) / 32) _GDIPlus_GraphicsDrawImageRectRect($hBackbuffer, $hImage, $x * $fw, $y * $fh, $fw -1, $fh -1, $fw + $i * $dx, $gfx_h / 2 - ($fh * $size / 2), $fw * $size, $fh * $size) Next _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, $heigth * $factor2, $gfx_w, $gfx_h) EndIf EndSwitch Return "GUI_RUNDEFMSG" EndFunc Func _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGraphics, "int", $iInterpolationMode) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_GraphicsSetInterpolationMode Func Extract_Bitmap() Local _ $Bitmap_Font = '0x89504E470D0A1A0A0000000D49484452000002000000008002030000000039399800000009504C5445FE00FE000000FEFEFE8676FDBE0000000174524E530040E6D866000009EA49444154785EED5A' $Bitmap_Font &= 'DD6AE4B81296A1E56B0FD80DADA7D1C24CAE3DE0043AD776407E1A2DCC0C24D7DDE1789EF2A8FE285BEAD39BD93DE7ECC5BAE08BD4FAFD5492AACA760C480BE8D39FCF09DE18EB7D0295579896221D6D' $Bitmap_Font &= '9F6020259826A543EA97F2DDA0E5B7C47ACE04C025757A4D85D118F77B342E5279CDA9F10C15AC7097040F29C18C295D52BF949F172DD759997B828B1901FB4A8DC3BB87DF58EE3CE1D3EF89602C0984' $Bitmap_Font &= '84D9434AA860C281D0052D6F0DC13C7BEA9A92E99211703FBD09AF8670F5665C11987EF88C004D16028DD906989056EEFA54DE4B3DC310EC35B57B34E6F82D2D4A09D019A8A7944F156E4AF8114D6374' $Bitmap_Font &= '1B4E8954F79DDA778F5B02CE439E263FB1CAE7848AF34A80C8CD69A11590D52D20398ED4C1BE79DC06A3046070EC0822691D8500E5AB806A15D56BFDA25B30C9028E1EFA91B494E0A13942C797983A42' $Bitmap_Font &= '6DA98196076833028036D0186D46C00625E07AE84F64ADC934704AEA7F09297D4F049ED704E40C485B39A04A200C94EF56FB2EF5F6B23E03A8413C03CEE704226DC1387BE3120993DD829200EF77942B' $Bitmap_Font &= '27FB9E5D4FEE17E816A0068237E5161C602F7B639A2E31FDEA37040C23481F5911A8D4ABD1313DA49981F2DA5EED00664BA9B2DF648854C68D19F83519CD2F4B698A9B8D25FEA068DF5276D9A57A64DF' $Bitmap_Font &= '9D6039ED06824D686DCA7BAA6B5BB168DE3415D4637B4DD1CA79E8436DBF7A4A5B1E130F34A5A6976BF6D3939D17270258082E21386FE69839952A9AB1F6500FED35457F11A10FB57D8F94061E13AF34' $Bitmap_Font &= 'A59578C2D36334B50C7EE674603C791CCC7936A7171EE0219A900884679C0853E9DF5DFD4D021DA46CC88EE0DC1626302DD138F1D9075CB112A8707071B7BA82B79848AC269274C0761B026296AB05FA' $Bitmap_Font &= 'AAE774EC6BCCCB2B11987175D459B62074E8389400AFE0250DFCF2A324305F9480A3008726C358614B20C01F2520FB9B696006359704A61FD14CEF488088437A85B370930042634C425BA9066095DB2D' $Bitmap_Font &= '304A06906FC1F810C163527DCFED30102908D0EA239357022AD34F5C65760899C0B312E8F01052DD5827028EFB193D84931078E695F378759431A13E23707A44C6C5350C065720D71021D769ACF91A4A' $Bitmap_Font &= 'BB45575DD1B5CC08F0982501BA0EADCD0D11FBEB47AEF30035284DC58648DA5DB19DC6030379D1EA407D2A8E1782A7BD3D46096EA1D160FEBACCFE63CD2210E0D490D1FAEF48F7C166C0B3C55435B0CB' $Bitmap_Font &= '2E6D964AA6EAF5A7BE2700DC177BAF72D078A008AD4356505FE4A79850C9DF1777E7608B479CFB8C80E5C7690B08943AC80F54DE4A9B96DA775FD6868B0D52AFFDDA368F88A85DFD0DFBAB211AC0141B' $Bitmap_Font &= '35C10EB0AC7E2FE2A6D99B058907C4746BBBA0BFA15D1911A109566DDA8ACCB3392458E9D06B67A779662D11910EACE0895103B70974171EC39026DC8337D359F66D9189D4E1382F0329EB391604143D' $Bitmap_Font &= 'D66B3F8D880A975C2DF4B43D9E0C8A7690FCE39F20805B29FD302F0408FE2304447DE7DB04C2E53E81EE225BC0933E7B8D07FAED168CC1ACB7A03C84CE433E2310B604F4106AB85D6B3CB022501EC2A6' $Bitmap_Font &= 'C5AD26D1070BCCEBB37DD0879163D43C5F2FBDBE410D4CB58A07ACA53ECEDFB986F7C45DFED8E507FE73DF386586E8A35ED8F67FECF25BFA73576C6E8AB56A975DB2A8B85B957B8245783990C6DE0824' $Bitmap_Font &= '5B418FD8886DD2B09F6E7F333834F45C70EBAEE9331D7F3F902BE96E84D24170416CC48D69D8170FFD0B398DD0E0C98B4130D5552B8FDF003CE83B69A042B34DED152501BB52D20BBE678ED81F166C3B' $Bitmap_Font &= 'EDD782DAE6AB9AC44A5962D9FC2F526978658FE69100D62928A6187945136B4DE4934702D81F173C6BFF801E6C50A7502F850650DCB4725073C4F60A8A291ADED3C693DDEF067DF0387D8F26F4E247B4' $Bitmap_Font &= 'BFBBB003194FA506EAA8042C4640E2AED18DAE918BBE67E2F372F05E63855446FD9880FB8D7EB44CA0EDC9D9D451B686BE1FB8E55708A806583456B86AFF3AF2219CCE99CF7F8F1B0D9C406D4162049F' $Bitmap_Font &= '6F41212E96659D68F02A5BC0046A3A101AF7290100CA387B3E84780DF3435888F565D91CF910BEC921E4F12BBE12239B8129E216882102C1EF07720DED63710D3F249DE76BF845FB554A942A3B48BDF9' $Bitmap_Font &= '07CA2EBBB4267B27D0EA1371836FD2CABB5DB1A5B372CD18F66650AAFD2D42DF396868EDF59D803E6A915DA897D2BAD56CEBE59BE2CC7032D1B00ECBB5BFFB8D10AAECE3B505677136A6392881702602' $Bitmap_Font &= 'A7278FDF0BAACAB060196800EBAB842323B006DDB28E73C8C2364DCA3F78844B1002A61567F159DC241318680BA66B24539C3A89BC5CB1B710D00FD8F284FDAA041C1318475824219CB22DC0A0A36722' $Bitmap_Font &= '17D9027DA31EA09CBFFB767D2A3B471E9CBEAA072F8F5C4AA0CD0840B99B04D916846FE4464F237841590913F80E1AE0817F426CA01AB086CBF0F97F4B20AC1C91E387D5D31B2124389F11703D119897' $Bitmap_Font &= '8C00C674F4BB7BF2AA0114D240E7138C12704A00EBAC2702F5EC31BE38A63434D9168401D40E1AD86EC184ABC501C8279B2D814AB22B0216B7A028270D38D6C288C53AD9BC48A040655DD0130F523F10' $Bitmap_Font &= '012D530DA8D038D56BFE359E0EA14D57F7103CA64E6F015DC36EA06B58C9B7A1B00E56F91A56DB32FD9F1295302881A356E13534A0C539429A1937F9916945AC9E4A59D63DE67D954028CCA21C8A0F98' $Bitmap_Font &= '67DBFF05D3FE59F37765975D2AFE965F01D2C1391C38FFE8F9759DD61F1AF5E39623683B503F6B8A7148AAF51C5CDEAF0E791DF96322E0D598D389F360282ED93FAA8DF20445E513A40BF573BE1807C5' $Bitmap_Font &= '3EF9D51C545EA9B3D32F990ECCE48556743AC36F6F025A45ADEF06984827EF3C3B98ABB6D371F42D6C97EA8FDFA9AEB56CEAC9B7B0CAF40D29B0041081034CAA9861302F602FF7144D78F2D85F411337' $Bitmap_Font &= '0D7D471674DDE6533FA432618990460F68D715014844850312EF91229C54AFC089D1F607F9CAAE60D7CEAF735CB88D79F11C1509E43B428627FE6786E70CE0F1C0A9BDDD2110EE10088043A18192C083' $Bitmap_Font &= 'FC3343891A34F47CA33CCA169027BB89808770A381DB0440D5B3AE5C411A28CB81801E42292C31478E1132C43568BF47E7212D308E9A5748BCC167A0B5FF019DE71821835F810D516321CD41B7602ACB' $Bitmap_Font &= 'F52368FF673E42FE3FFF85CF9AFFBDECB28BFA71CF7EBCC1BC48190F5099C6030DA11CE7D61C502EF100E5D58F47F6E323E545CA7860EB92DD4828C7E1851CD675502EF100E6A1502AD88FF794B75F28' $Bitmap_Font &= 'AF7E9E7E3B0F9D251EA0BA97988FA37DED59DEBC535DDB6A3CD05258B485BB30DE3CA45A3750B935FA95D4799AACEB6F8D4304D4F3E18492176724132A6C2074E0E1D684B883F3DB6DB03C98CB103882' $Bitmap_Font &= '0AE12E7842853A0DF08866DB785E7202D456DB94ED4359AF8BB99AC25369C35459464439817BABE3302EDC2420695E9911E8B378E0FC6B04EA78A71C53D54009FA4690A124A0ABC92187F0763C3073BD' $Bitmap_Font &= 'F8E8125D42CC4FB7DE022BA0EB54B663C333F5F9D8BC881ED2BF291E502DFE2DF1C0568BBBECB2CB2EBBECB2CB2EBBECF26FA1A2D2830F13B5A20000000049454E44AE426082' $hFile = FileOpen("fontjs.png", 18) FileWrite($hFile, $Bitmap_Font) FileClose($hFile) EndFunc I added the image as binary string because I don't have enough attachment space left here! I don't have any idea how to colorize letters currently. Maybe later...Br,UEZ Edited December 10, 2010 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
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