有谁会用ASCII画图? 有相应算法没?(200分)

  • 主题发起人 主题发起人 cheka
  • 开始时间 开始时间
C

cheka

Unregistered / Unconfirmed
GUEST, unregistred user!
.;
.`;'
. ` ;;'
. ` ` ` ;;;'
` @ ;;;
` ;;;
` ;;;;
` ;;;;;.
` .;;;;;;**.
` ;`* .;;; `**.
. ` ;;`****. '*.
'** ` ;;;;'****. .
'****` ;;;;;`***.
'*****` ;;;;;; `**.
` **` ;;;;;;; .*
`*` ;;;;;;;;
` ;;;;;;;; ` ;;;;;;;;
` ;;;;;;; ` ;;;;;; . *
` ;;;; ***
. ;; *** * * . ;; **
*** * ` .;; *
** .****. * *
* . * ^^ *'. * ****
* * * **** *** * * ***
*** ** * ***
*** **

就像上面这个(能看出是什么东东吗?)

好像有软件可以把图片转化为ASCII Graph的,
挺想做一个玩玩儿的(是不是有点自不量力)?
有啥思路可供参考,具体和抽象都行,不限发挥。

能提供源码的或是带源码组件的俺另外给分啦。


 
海豚

http://home.gbsource.net/spiceboy/ascii/ascii.htm
 
Please view in a fixed-width font such as Courier.

====*;;==;;;=;;;;;;;:;;==**=*****&&&&%*&*&&&j*&*&&&&*&&&****
**********=*******&*******&&***&**3MMMMMMMNNMMNMNNN@%&&&&*=*
***=*==*****==;;=;;;;===*****=%NMMMMMMMMMNHHNHH@MHMNHN@Hj!::::~ !!::!;:!:!
;===;=;=====;=;;:;;==:=*:!:&MMMMMMMMMN@HN@H@H#H@HH@NHHHNNM@!!!:` `:;:&j%j%
;:;:::;;::!!!:';::!!;::::SMMMMNNNNN#HHMMNNNNNNMNN@@AUAHMMMMMR%%jj&%%jjj&%j
*&&~:%~`'!!:~&*!~!::!;:=MMMMMNMNHH@@M@@RARR#@R4UA@@@#@HNMMMMM#j%j$jjjjjj33
&&*&%;!::;::!:;:!!~!!:~MMMMH@4S$8$S4AA$S%&$j&4UR#H@@@##@NMMMMMHj%j3jj$j$%j
*%%&**%!:!!:j=!:~~:!::@MMRSj&**;::::!!!~'~!!**&$S8R@HHHMNMMMMMM$3jjjj3j%$&
=&:!:~``~`''!&&%!!!::!MMR$j&=:::!~!''`` `''!:=*jjSU#@HHNMMMMMMNjj&jj%j&%$
!!!!!!'`''!!'~:!~!:!!!MN$%&&=:~!!''`` '''!!!*&j8##HMMMMMMMM$&%jj3&j$3
:!!'!``~!!!`!~''!` '``MH3&*=:!!'`````` ``''~'~!;*j&8RHMMMMMNMjj3$3$$3$$
*~:=;!'` '` '!'!!!!!:M@j*=:!!'``````` ``''~!:=&%$R#HMMMMMH$$j33j833%
*:!!*&*!~!!:::::=;=&&*@H8RU4S3&:'```````!&&$S$$$S3*****38@MMMMMM3$jj3j$33j
$$S$S$$$*%&**%&%*&%3&j$H%*;::=***:~```'!!:!!~~~'!:=j%***&3HMMMN==$3j$33j3j
$8S83j$$S4jjj%&%%&&%jj&4$$4S$*=:=;:'` '~!;;%$43$3&&;::!=*%@NMM=!j*88$j3$$3
84US4U8884USS$$jjj&jjjj*:*Aj'@U!j!;' '~'3j:%8$8S:''''!;*&U@83*':`$jj$33S8
SjSS3U$8$S$33S$j3$3$SSj*!~''~''`'!;` `` ```` `''~!*&%U3&~''=$$j$jjj%3
$48S484U4SAA$S$$j$SjS$$&!` `'!:` ```` `'!;&jSS$::'`$3$3j$j*%&
SU$4UU4SS4S%8Sj$SS33$44$!'` ``;=' '~!'`` `'~:*jj$&!~!!jj3%jjS8S3j
&$A4$US3jU8888AS$83S88S3*:'` `':;'```~'`=~'`` `'~::&jjS&!:M$3j$3SS33j3j
UAUA4U4S8A4U8UUSSU44U44Sj&:~''~::*&j*:'''~~'':''`'!:=;=j$8MMMMMjSS$$$S$S83
SU4U8#SURA4A4S4UA4AS$84UU4&:!~!*=**&;~=&***=*:~'`'~::;&j84MMMMMHj8S$3SS$$$
88RAA8@34A33S4UUS$4UU48AU$4&:`':$! *%%''``'~!!=%jS8RMMMMMM#4U43484U$
j$$%j8RSAAA8#UR#ARR4UA48848A*:'';$&&*;!!&j:~`'''~!:;%$$$4UMMMMMMMMSS88$%$$
%j%&%&&&j38UA8$UU@RA*$A8$$U$4&;:!!!!!!~`````'''!::*3$jj$88MMMMMMMM4$S4$$4S
3$%%%3j%%%j3%%&j:* ~j`A484U$S$S&:''```` ```'~:;%jj%&%%$$SMMMNMMMMMSS484$j
jjjjjj3j3j%j%jjjj%%&=**&j8Uj8S3$j:''```````~*&%&j===**%33j#@NMNNMNNN#S4348
8SS$j3$j3%%jj3&&=3$8S%3j3;&*j3S4SSR$3jjj&j333&*;=;;;;=&&&&3UMNHMMMNH@@U88$
S$$S%%$j3&jj$j%%%4%3=!Uj3$S$$$$$S$3S$$jjj3j&=:;::!!:::;=***%jMHMMMMMMM8U$4
Ajj&$jj$j$%%j3jS$=& `&j$jSj$$$Sj$S3$$3jj%j&==;:!!!!!!!!!::;=&%$MMMM@MNR4UR
@@8%S3$%SSS$$8Rj34$%S$S33$j&:;*&348S3j%%%=;:!!!:!!~~'~'''~~!!:**3MNNNM4U88
HR#4S$3%j` $$S3$SSS$$3%&=**!::j$$$$$%j%%*::!!!!!~'!''''`'``'`'!!:=*NM#SS8S
$3HA&*=j;:=~ '&3$S3=;:::;~!~!&%j3:;:;%&:::!!:'`'~~~'''''~~!!!~```':&*$$$88
SA@@Rj3%%%&*&jS%*:=:!!!!~`'&%%%j:**:&:!:::::::!!~''''``'`` `` ```'~~~'!j3
AHU##&*%j%&%&&**%&=:!!'~`~:**jj&;;%=*;::::!~'` ```` `` :=:::::;=%$~A
@#@HHRA#U%%*jj= =*=;~''``!*=&&&=!=:::!::!!!'''``````````` :=;:!!~~''~!!:*j
HHH@NRMR! 384jj8j%*`''''=*=*%%j:;::::::!!!~~~'` `````` !;;:!~'`````''!~!:;
HH#@@H@@$S8j4j$$$!~'``~!;==***==;:::::!~''` ` `` &!:;:!''` ` ``'!!::
HH@R@#HA&=&=&=&*`!''`' =========;:!!~'` ````` %~~!:;!'''` ``''~!::
HU#RR4$%jj%*&&*!''```'`~==;===;:!!' ```` ``` *```'!!!!~'`` ```''!::
`~$%AAUU88S88S!'`````````:;*==! ` ``` ``!`````'~~!~~'```` ``'''~!;
:%&*43AUU4U#R''`````````````` ` ``` ` ```'~'~'`''``````'''~!:
##U#AS4884Uj'````` ``` ` ``*` ```'''~''''`` ` ```''~:!
@UU8SURU4$'``````` ````` ``~` ` ``'':~'~''```` ```''~;:
RUR@A484``````````` `` ``'` ``'!*:!~~'''`` `` ``'''~!
@#R4483'````````````` `` `` `'`!&=!!'''``` ``'~!
#RA43````````````` ` ``` ```':!%!~''`'``` `'''!!
RAU:``````````````` ` ` ``''~:j!~~`````` ``''!!
R4: ` ```````````` ````''~=!~'``'`` ````'!'
UA``````````` `` ` ```'`~!~~'```` ` ```'''!!
U$'``````````````` ````````':!~'''``` ``''!!!
UU`'''```''''```` ````````````:!~~'''``` ``''!::
RUA''~''''''''```` `````````````;:!~''``` ``'!!::
AARU!~~~~''''''`` ``````````````::!~''``` ``''~!::
#4$jj~~~~~~!~~~``` ``````````````'=:!~~'` ` ```''~!:;
@@UU8SU!!!~~~!~~~```` `````````````''=:!~''```` ``'!!!::
##RU444U!!!!!~~~~~''```` `` `````````````'';:!''' ` ````'~~~::
@@RAURAUU!!!~~~~~~~~~''```````````` ` ` `````'```'''=:!~''```````'~~!;;
@RRUUUU488~~~'''''''~'~'''`''''`'`''''``` ````'';;:!'''`` ` `''~~;;
#4U$848S8S8!!!~''''`''``'''``````'```````~~!~~''``````'*:!''''````'``'~:;*
 
如果使用单一字符, 可以吧图像读入image, 再根据canvas.cells
打出ascii 图像. 只是太单调了,
如何决定使用那个字符? 使用多种字符的图像, 才会有效果
洗耳恭听,
要么, 你可以作一个工具, 提供画布, 让人来华,
如:
用image现实图片, 在上面描上网线, 就可以用鼠标或键盘
对照在相应的方格内填上适当的字符. 然后把他保存为ascii 文本
文件
 
猜得出这是谁吗?
<font face="Courier"> Please view in a fixed-width font such as Courier.


MMMMMMMNNMMNMNNN@
%NMMMMMMMMMNHHNHH@MHMNHN@
&amp;MMMMMMMMMN@HN@H@H#H@HH@NHHHNNM@
SMMMMNNNNN#HHMMNNNNNNMNN@@AUAHMMMMMR
=MMMMMNMNHH@@M@@RARR#@R4UA@@@#@HNMMMMM#
~MMMMH@4S$8$S4AA$S%&amp;$j&amp;4UR#H@@@##@NMMMMMH
@MMRSj&amp;**;::::!!!~'~!!**&amp;$S8R@HHHMNMMMMMM$
MMR$j&amp;=:::!~!''`` `''!:=*jjSU#@HHNMMMMMMN
MN$%&amp;&amp;=:~!!''`` '''!!!*&amp;j8##HMMMMMMMM
MH3&amp;*=:!!'`````` ``''~'~!;*j&amp;8RHMMMMMNM
M@j*=:!!'``````` ``''~!:=&amp;%$R#HMMMMMH
@H8RU4S3&amp;:'```````!&amp;&amp;$S$$$S3*****38@MMMMMM
$H%*;::=***:~```'!!:!!~~~'!:=j%***&amp;3HMMMN==
4$$4S$*=:=;:'` '~!;;%$43$3&amp;&amp;;::!=*%@NMM=!j
*:*Aj'@U!j!;' '~'3j:%8$8S:''''!;*&amp;U@83*':
*!~''~''`'!;` `` ```` `''~!*&amp;%U3&amp;~''=
!` `'!:` ```` `'!;&amp;jSS$::'`
!'` ``;=' '~!'`` `'~:*jj$&amp;!~!
*:'` `':;'```~'`=~'`` `'~::&amp;jjS&amp;!:M
&amp;:~''~::*&amp;j*:'''~~'':''`'!:=;=j$8MMMMM
&amp;:!~!*=**&amp;;~=&amp;***=*:~'`'~::;&amp;j84MMMMMH
&amp;:`':$! *%%''``'~!!=%jS8RMMMMMM#
*:'';$&amp;&amp;*;!!&amp;j:~`'''~!:;%$$$4UMMMMMMMM
;:!!!!!!~`````'''!::*3$jj$88MMMMMMMM
&amp;:''```` ```'~:;%jj%&amp;%%$$SMMMNMMMMM
j:''```````~*&amp;%&amp;j===**%33j#@NMNNMNNN
R$3jjj&amp;j333&amp;*;=;;;;=&amp;&amp;&amp;&amp;3UMNHMMMNH
$$jjj3j&amp;=:;::!!:::;=***%jMHMMMMMMM
$3jj%j&amp;==;:!!!!!!!!!::;=&amp;%$MMMM@MN
S3j%%%=;:!!!:!!~~'~'''~~!!:**3MNNNM
$$$%j%%*::!!!!!~'!''''`'``'`'!!:=*NM
&amp;%j3:;:;%&amp;:::!!:'`'~~~'''''~~!!!~```':
'&amp;%%%j:**:&amp;:!:::::::!!~''''``'`` `` ```'~~~
~`~:**jj&amp;;;%=*;::::!~'` ```` `` :=:::::;=
~''``!*=&amp;&amp;&amp;=!=:::!::!!!'''``````````` :=;:!!~~''~!!:
`''''=*=*%%j:;::::::!!!~~~'` `````` !;;:!~'`````''!~!:
!~'``~!;==***==;:::::!~''` ` `` &amp;!:;:!''` ` ``'!!::
`!''`' =========;:!!~'` ````` %~~!:;!'''` ``''~!::
!''```'`~==;===;:!!' ```` ``` *```'!!!!~'`` ```''!::
!'`````````:;*==! ` ``` ``!`````'~~!~~'```` ``'''~!;
''`````````````` ` ``` ` ```'~'~'`''``````'''~!:
j'````` ``` ` ``*` ```'''~''''`` ` ```''~:!
'``````` ````` ``~` ` ``'':~'~''```` ```''~;:
``````````` `` ``'` ``'!*:!~~'''`` `` ``'''~!
'````````````` `` `` `'`!&amp;=!!'''``` ``'~!
````````````` ` ``` ```':!%!~''`'``` `'''!!
``````````````` ` ` ``''~:j!~~`````` ``''!!
` ```````````` ````''~=!~'``'`` ````'!'
``````````` `` ` ```'`~!~~'```` ` ```'''!!
$'``````````````` ````````':!~'''``` ``''!!!
`'''```''''```` ````````````:!~~'''``` ``''!::
''~''''''''```` `````````````;:!~''``` ``'!!::
!~~~~''''''`` ``````````````::!~''``` ``''~!::
~~~~~~!~~~``` ``````````````'=:!~~'` ` ```''~!:;
!!!~~~!~~~```` `````````````''=:!~''```` ``'!!!::
!!!!!~~~~~''```` `` `````````````'';:!''' ` ````'~~~::
!!!~~~~~~~~~''```````````` ` ` `````'```'''=:!~''```````'~~!;;
~~~'''''''~'~'''`''''`'`''''``` ````'';;:!'''`` ` `''~~;;
!!!~''''`''``'''``````'```````~~!~~''``````'*:!''''````'``'~:;*
</font>
 
巩利?
真不错, 自己画的? 累坏了?
 
好玩儿,再来几个!
 
是呀,单一字符的东西我写过,把图片先锐化的不能锐化,再转化为二值图像,然后......做出来的好恶心呀。 不过写一个画板倒是不错的主意,可惜对我这样的画盲还是没用。
 
关键是算法,谁有?C源码也成!
 
好像有现成的软件的,到国外的大下载站点找找看,我以前见到过.
 
刚发现了一个有C源码,但下载连接坏了,待下载好测试过再汇报.
 
算法不算难吧?
其实思路很简单嘛.
可以将一个可打印字符认为是由9格组成的brush, 比如"`", 就是左上角是黑色
其他部分是白色的brush, 将所有可打印字符做成不同的brush, 然后分割要
转换的图象, 比较每块, 套用不同的brush填入呗.
 
呵呵,有趣,继续
 
下面是一个VC的例子,抄别人的.

CString strBmpPath;
CFileDialog dlg(true,NULL,NULL,OFN_HIDEREADONLY|OFN_FILEMUSTEXIST
,"位图文件(*.bmp)|*.bmp||");
if(dlg.DoModal()==IDOK)
{
strBmpPath=dlg.GetPathName();
CBitmap* pBitmap=new CBitmap;
pBitmap=CBitmap::FromHandle((HBITMAP)LoadImage(NULL,strBmpPath,
IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_DEFAULTSIZE ));
BITMAP stBitmap; //生成结构
pBitmap->GetBitmap(&amp;stBitmap); //结构赋值
/////////////
CDC* pDC=GetDC();
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap *pOldBitmap=memDC.SelectObject(pBitmap);
CString strText;
COLORREF Color;
int nValue;
//////////////////
BYTE CharPalette[16];
CharPalette[0] = '#';
CharPalette[1] = 'M';
CharPalette[2] = '@';
CharPalette[3] = 'H';
CharPalette[4] = 'X';
CharPalette[5] = '$';
CharPalette[6] = '%';
CharPalette[7] = '+';
CharPalette[8] = '/';
CharPalette[9] = ';';
CharPalette[10] = ':';
CharPalette[11] = '=';
CharPalette[12] = '-';
CharPalette[13] = ',';
CharPalette[14] = '.';
CharPalette[15] = ' ';
///////////////////////////////////
for(int i=0;i {
for(int j=0;j {
Color=memDC.GetPixel(j,i);
//计算灰度值
nValue = (GetRValue(Color) * 30 + GetGValue(Color) * 59 + GetBValue(Color) * 11) / 100;
//转换到文本
strText+= CharPalette[nValue / 16];
}
strText+="/r/n";
}
strBmpPath.GetBufferSetLength(strBmpPath.Find(dlg.GetFileName())); //找到
CString strTxtPath=strBmpPath+dlg.GetFileTitle()+".txt"; //源文件名

CFile LogFile(strTxtPath,CFile::modeWrite|CFile::modeCreate | CFile::shareDenyNone);

LogFile.Write(strText.GetBufferSetLength(strText.GetLength()),
strText.GetLength());
LogFile.Close(); //关闭文件

//////////////////////////////////
memDC.SelectObject(pOldBitmap); //选入老的
pBitmap->DeleteObject();
ReleaseDC(pDC);
}

 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部