我们的程序要和外设(LED)通信,LED要求不管数据来源是文本还是图片或其它的数据,都必须将其转化为图片,此图片的色值只有红、黑、黄、绿四种颜色。问题是对 4 行字符串,用什么方法可以转换为图片啊?
解决方案 »
- 扫描局域网所有机子的端口开放状态,检查某个网络软件是否安装
- 用户进程中发生浮点异常错误。已取消当前事务。怎么解决
- 帮个忙,谁有将mpg文件转换成DVD文件的源码!不胜感激!
- 谁能帮忙把这段C代码翻译成DELPHI
- WM_DROPFILES消息怎么用?一个界面上怎么让多个组件同时支持windows外部文件拖拽。DragAcceptFiles。
- 求助:DELphi 怎样美化界面?
- 刚学delphi,问几个基础的问题
- 诚聘开发人员
- 关于考勤系统的思路,请有做考勤系统经验的高手指点
- 多线程查询问题,急!
- Delphi判断linux服务器down机
- 急啊!!!!求大家了!!!帮帮忙!!!!在线等!!!!
BaseTable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
SMTP_RES_EX: array[1..9] of String = ('250', '334','334','235','250','250','354','250','221');
function EncodeBase64(Source: String):String;
var
Times, LenSrc, i: Integer;
x1, x2, x3, x4: Char;
xt: Byte;
begin
Result := '';
LenSrc := Length(Source);
if LenSrc mod 3 = 0 then
Times := LenSrc div 3
else
Times := LenSrc div 3 + 1;
for i := 0 to Times - 1 do
begin
if LenSrc >= (3 + i * 3) then
begin
x1 := BaseTable[(ord(Source[1 + i * 3]) shr 2)+1];
xt := (ord(Source[1 + i * 3]) shl 4) and 48;
xt := xt or (ord(Source[2 + i * 3]) shr 4);
x2 := BaseTable[xt + 1];
xt := (Ord(Source[2 + i * 3]) shl 2) and 60;
xt := xt or (Ord(Source[3 + i * 3]) shr 6);
x3 := BaseTable[xt + 1];
xt := (ord(Source[3 + i * 3]) and 63);
x4 := BaseTable[xt + 1];
end
else if LenSrc >= (2 + i * 3) then
begin
x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2) + 1];
xt := (Ord(Source[1 + i * 3]) shl 4) and 48;
xt := xt or (Ord(Source[2 + i * 3]) shr 4);
x2 := BaseTable[xt + 1];
xt := (Ord(Source[2 + i * 3]) shl 2) and 60;
x3 := BaseTable[xt + 1];
x4 := '=';
end else
begin
x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2)+1];
xt := (Ord(Source[1 + i * 3]) shl 4) and 48;
x2 := BaseTable[xt + 1];
x3 := '=';
x4 := '=';
end;
Result := Result + x1 + x2 + x3 + x4;
end;
end;
var
fs: TFileStream;
ss: TStringStream;
begin
if OpenDialog1.Execute then
begin
fs := TFileStream.Create(OpenDialog1.FileName, fmOpenRead);
ss := TStringStream.Create('');
try
ss.CopyFrom(fs);
Base64Encode(SS.DataString);
...
finally
fs.Free;
ss.Free;
end;
end;
end;