图像二值化后16进制字符如何显示,急死我了!

xmyyzhen 2008-05-07 07:27:25
数据库中存着别人存好的16进制字符,如何还原显示为图像,请各位帮忙啊
以下是数据库中取出的二值化字符
例一:3070FF0780C1013CE01FEC3FF0033070FF0780C1013CE01FEC3FF00308600E0F80E3001E70382C1FFC0F08610E1E00E3000770F03C001C0E08610E1E00E3000770F03C001C0ED8630E1E007B000778E038001C0CC8670C0F0076800158E038001C0CC8670C0F0076800158E038001C0C4969FC070034C00178E0B8031C0EC96F2C07003CC00570E0F81F580FC96F2C07003CC00570E0F81F580F59630C0E003CC07F78E00038040519610C1E003CE0E078E000780400196F0C1C003CE0C078E000700C00196F0C1C003CE0C078E000700C0019610C1C003CE0C070E00070040019600C1E003CC0C070E03878042C19600C1E003CC0C070E03878042C1960FC0F0038C0E160F030781C2C1140FC070038007FC03FF01FF80F

例二:2100fc0fc00f00020000fc0000402100fc0fc00f00020000fc00004001201c00c07f0007e007fc03f80101200c00c0e0010338187c0f0e8201200c00c0e0010338187c0f0e8201210c00c0e001021c381c0e0786c13f0c00c0c001021c380c1e0784c13f0c00c0c001021c380c1e0784f11f3e00e0c001021c381c1e0784f10ffe03e0c003061c38fc0f0584f10ffe03e0c003061c38fc0f0584d1432e00e0c002061c38fc0f058401230e00c0c003061c383c0e078401220c00c0c003061c380e8e078401220c00c0c003061c380e8e0784013e0c00c0c101071c380e9c070401201c00c0c101061c380c1c070601201c00c0c101061c380c1c07060120fc07c0f30107381c1c0f0f060100fc1fc07f0007f80ffc0ffe47
...全文
175 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xmyyzhen 2008-05-13
  • 打赏
  • 举报
回复
已解决,图像仅写入黑白信息,宽度112,解决如下
unit uFrmMain;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TFrmMain = class(TForm)
mmoHex: TMemo;
pbPlate: TPaintBox;
btn1: TButton;
btnExit: TButton;
lbl1: TLabel;
mmoNext: TMemo;
procedure pbPlatePaint(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btnExitClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FValidBuffer: Boolean;
FBuff: array[0..2239] of Byte;

procedure prShowPlate;
function fnTruncate(AValue: string): string;
function fnHexToByte(AData: Char): Byte;
public
{ Public declarations }
end;

var
FrmMain: TFrmMain;

implementation

{$R *.dfm}

procedure TFrmMain.pbPlatePaint(Sender: TObject);
begin
with pbPlate.Canvas do
begin
Brush.Color := clBlack;
FillRect(ClientRect);

if FValidBuffer then
prShowPlate;
end;
end;

procedure TFrmMain.btn1Click(Sender: TObject);
var
I: Integer;
J: Integer;
FLoValue: Byte;
FHiValue: Byte;
FText: string;
FLen: Integer;
begin
FillChar(FBuff, SizeOf(FBuff), 0);

FText := fnTruncate(UpperCase(mmoHex.Text));
FLen := Length(FText) div 2;
J := 0;
for I := 0 to FLen - 1 do
begin
FHiValue := fnHexToByte(FText[I * 2 + 1]);
FLoValue := fnHexToByte(FText[I * 2 + 2]);
FBuff[J] := FLoValue and 1;
FBuff[J + 1] := (FLoValue shr 1) and 1;
FBuff[J + 2] := (FLoValue shr 2) and 1;
FBuff[J + 3] := (FLoValue shr 3) and 1;
FBuff[J + 4] := FHiValue and 1;
FBuff[J + 5] := (FHiValue shr 1) and 1;
FBuff[J + 6] := (FHiValue shr 2) and 1;
FBuff[J + 7] := (FHiValue shr 3) and 1;

Inc(J, 8);
end;

FValidBuffer := True;
pbPlate.Invalidate;
end;

procedure TFrmMain.btnExitClick(Sender: TObject);
begin
Close;
end;

function TFrmMain.fnHexToByte(AData: Char): Byte;
begin
case AData of
'1'..'9': Result := Ord(AData) - Ord('0');
'A'..'F': Result := Ord(AData) - Ord('A') + 10;
else
Result := 0;
end;
end;

function TFrmMain.fnTruncate(AValue: string): string;
var
I: Integer;
begin
Result := '';

for I := 1 to Length(AValue) do
begin
if AValue[I] In [#10, #13] then Continue;

Result := Result + AValue[I];
end;
end;

procedure TFrmMain.FormCreate(Sender: TObject);
begin
mmoHex.Text := UpperCase(mmoHex.Text);
FValidBuffer := False;
end;

procedure TFrmMain.prShowPlate;
var
I: Integer;
FRow: Integer;
FCol: Integer;
begin
with pbPlate.Canvas do
begin
for I := 0 to 2239 do
begin
FRow := I mod 112;
FCol := I div 112;

if FBuff[I] = 1 then
Pixels[FRow, FCol] := clWhite
else
Pixels[FRow, FCol] := clBlack;
end;
end;
end;

end.
gobiz 2008-05-08
  • 打赏
  • 举报
回复
不知是什么图片格式,现在假设是BMP格式的图片,示例如下:
var
i: Integer;
s: String;
FStream: TMemoryStream;
b: Byte;
begin
s := Edit1.Text;
FStream := TMemoryStream.Create;
try
FStream.SetSize(Length(s) div 2);
for i:=0 to Length(s) div 2 - 1 do
begin
b := StrToInt('$' + s[i*2+1] + s[i*2+2]);
FStream.Write(b, 1);
end;
FStream.Position := 0;
FStream.SaveToFile('C:\图片.bmp');
finally
FreeAndNil(FStream);
end;
end;
xmyyzhen 2008-05-07
  • 打赏
  • 举报
回复
尺寸应该是280×40
xmyyzhen 2008-05-07
  • 打赏
  • 举报
回复
neweipeng 请进一步指导,拜托了
xmyyzhen 2008-05-07
  • 打赏
  • 举报
回复
谢谢回复,我也不清楚图像尺寸,一定要知道这个数值吗?如果一定需要知道,我只能再打电话问厂家了
neweipeng 2008-05-07
  • 打赏
  • 举报
回复
图像是多大尺寸?

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧