TA的每日心情 | 奋斗 2020-6-5 22:18 |
---|
签到天数: 22 天 [LV.4]偶尔看看III
|
发布资源
技术领域: |
游戏开发 » 美术资源 » 代码类 |
语言类型: |
简体中文 |
版本或日期: |
取图片结构的祥细信息 |
相关截图: |
|
下载地址1: |
天翼云下载:https://cloud.189.cn/t/3ui63abiyque(访问码:5wuu) |
下载地址2: |
百度云下载 : https://pan.baidu.com/s/1-Kj9_gbIHMGFkjd5c7w0yQ 提取码: kqsw |
欢迎您注册加入!这里有您将更精采!
您需要 登录 才可以下载或查看,没有账号?注册
x
哎感觉没多大用处的,当时写这程序时主要用于研究图形图像验证码部分,后面没研究了。
[Delphi] 纯文本查看 复制代码 function ConverStr(S: String): String;
const
HexHead: String = ' Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F';
var
SL: TStringList;
I,J,K,L: Integer;
StrHex,StrChr,StrOut: String;
begin
StrOut := '';
StrOut := StrOut + HexHead + #13#10;
if(Length(S) = 0) then
begin
Result := StrOut;
exit;
end;
SL := TStringList.Create;
SL.Text := StringReplace(Trim(S),' ',#13,[rfReplaceAll]);
J := 0;
StrOut := StrOut + IntToHex(J,8) + ' ';
StrHex := '';
StrChr := '';
for I := 0 to SL.Count - 1 do
begin
StrHex := StrHex + SL.Strings[I]+' ';
if(SL.Strings[I] = '00') or
(SL.Strings[I] = '09') or
(SL.Strings[I] = '0A') or
(SL.Strings[I] = '0D') or
(SL.Strings[I] = 'FF') then
begin
StrChr := StrChr + '.';
end
else begin
StrChr := StrChr + Char(StrToInt('$'+SL.Strings[I]));
end;
if(((I+1) mod 16) = 0) then
begin
StrOut := StrOut + StrHex + #9 + StrChr + #9 + #9#13#10;
J := J + $10;
StrOut := StrOut + IntToHex(J,8) + ' ';
StrHex := '';
StrChr := '';
end;
if(I = SL.Count - 1) then
begin
K := 16 -(SL.Count mod 16);
for L := 0 to K - 1 do
begin
StrHex := StrHex + ' ';
end;
StrOut := StrOut + StrHex + #9 + StrChr;
end;
end;
SL.Free;
Result := StrOut;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
PicDataLen:Integer; //读取图片数据的字节总数
//PicDataArray:array of Byte ; //图片数据数组
i:Integer ;
PicTF:TFileStream ;
PicDataStr:string ;
PicPath:string ;
begin
OpenDialog1.Filter:='*.jpg';
PicPath :='https://www.wgbcw.com';
if OpenDialog1.Execute then
begin
try
Image1.Picture.LoadFromFile(OpenDialog1.FileName); //OpenDialog1.FileName
PicTF :=TFileStream.Create(OpenDialog1.FileName,fmOpenRead);
PicTF.Position :=0;
PicDataLen :=PicTF.Size ;
SetLength(PicDataArray,PicDataLen +1);
PicTF.Read(PicDataArray[0],PicDataLen );
if PicDataLen >0 then
begin
for i:=0 to PicDataLen-1 do
PicDataStr :=PicDataStr + IntToHex(PicDataArray[i],2)+' ';
Memo1.Text :=ConverStr(PicDataStr);
end;
finally
PicTF.Free ;
end;
end;
end;
procedure WordLoHiExchange(var w:Word); //高低位互换
var
b:Byte;
begin
b:=WordRec(w).Lo;
WordRec(w).Lo:=WordRec(w).Hi;
WordRec(w).Hi:=b;
end;
function GetHiByte(B: Byte ):Byte;
begin
Result :=B shr 4;
end;
function GetLoByte(B: Byte ): byte;
begin
Result :=B and $0F;
end;
function GetPiCData(P:Pointer;nTpye:Integer):string ;
var
wStr:Word ;
begin
case nTpye of
1:Result := IntToHex(Pbyte(DWORD(p))^,2);
2:begin
wStr := PWord(DWORD(p))^;
WordLoHiExchange(wStr);
Result := IntToHex(wStr,4);
end;
end;
end;
procedure AddListView(s:string ;nType:Integer );//取图形结构加进ListView列表
var
Listtmp:TListItem ;
B:string ;
LhbJD:Byte ;//量化表精度
LhbID:Byte ;//量化表ID
Lhblen:Integer ;//量化表长度
LhbStr:string ;//量化表字串
i:Integer ;
begin
B :='2字节';
Listtmp := Form1.ListView1.Items.Add ;
Listtmp.Caption :=IntToHex(nType,4);
case nType of
0:begin
Listtmp.SubItems.Add(IntToHex(nType,4));
Listtmp.SubItems.Add(B);
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('图像开始标识');
Listtmp.SubItems.Add('(SOI)Start of Image');
end;
2:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add(B);
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('APP0标识开始JFIF应用数据块');
Listtmp.SubItems.Add('APP0(JFIF application segment)');
end;
4:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add(B);
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('APP0块的长度');
Listtmp.SubItems.Add('length of APP0 block');
end;
6:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('5字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('JFIF0标识符');
Listtmp.SubItems.Add('JFIF0 identifier');
end;
11:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add(b);
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('图形主版本号+次版本号');
Listtmp.SubItems.Add('Major version+Minor version');
end;
13:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('1字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('X和Y的密度单位');
Listtmp.SubItems.Add('Units for the X and Y densities');
end;
14:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('X方向像素密度');
Listtmp.SubItems.Add('Xdensity');
end;
16:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('Y方向像素密度');
Listtmp.SubItems.Add('Ydensity');
end;
18:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('1字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('缩略图水平像素数目');
Listtmp.SubItems.Add('thumbnail horizontal pixels');
end;
19:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('1字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('缩略图垂直像素数目');
Listtmp.SubItems.Add('thumbnail vertical pixels');
end;
20:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('量化表开始');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
22:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('量化表长度');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
24:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('1字节');
LhbJD := GetHiByte(Pbyte(DWORD(@NewPicDataArray[nType]))^); //HiByte(StrToInt(s));
LhbID := GetLoByte(Pbyte(DWORD(@NewPicDataArray[nType]))^);//loByte(StrToInt(s));
case Integer(LhbJD) of //P/T(高四位:精度,低四位:表ID) mh 1字节 精度, 0 表示 8 bit, 1表示 16 bit;ID取值范围为0~3, 否则错误
0: Listtmp.SubItems.Add('高四位:精度0x'+ IntToHex(LhbJD,2)+'/8 bit'+'低四位:ID0x'+ IntToHex(LhbID,2));
1: Listtmp.SubItems.Add('高四位:精度0x'+ IntToHex(LhbJD,2)+'/16 bit'+'低四位:ID0x'+ IntToHex(LhbID,2));
end;
Listtmp.SubItems.Add('量化表精度/ID');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
25:begin
Lhblen := 64* (LhbJD +1);
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add(IntToHex(Lhblen,2)+'字节');
for i:=0 to Lhblen -1 do
begin
LhbStr := LhbStr + IntToHex(Pbyte(DWORD(@NewPicDataArray[nType+i]))^,2);
end;
Listtmp.SubItems.Add('0x'+ LhbStr);
Listtmp.SubItems.Add('量化表表项');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
89:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('量化表开始');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
91:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('量化表长度');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
93:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('1字节');
LhbJD := GetHiByte(Pbyte(DWORD(@NewPicDataArray[nType]))^); //HiByte(StrToInt(s));
LhbID := GetLoByte(Pbyte(DWORD(@NewPicDataArray[nType]))^);//loByte(StrToInt(s));
case Integer(LhbJD) of //P/T(高四位:精度,低四位:表ID) mh 1字节 精度, 0 表示 8 bit, 1表示 16 bit;ID取值范围为0~3, 否则错误
0: Listtmp.SubItems.Add('高四位:精度0x'+ IntToHex(LhbJD,2)+'/8 bit'+'低四位:ID0x'+ IntToHex(LhbID,2));
1: Listtmp.SubItems.Add('高四位:精度0x'+ IntToHex(LhbJD,2)+'/16 bit'+'低四位:ID0x'+ IntToHex(LhbID,2));
end;
Listtmp.SubItems.Add('量化表精度/ID');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
94:begin
Lhblen := 64* (LhbJD +1);
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add(IntToHex(Lhblen,2)+'字节');
for i:=0 to Lhblen -1 do
begin
LhbStr := LhbStr + IntToHex(Pbyte(DWORD(@NewPicDataArray[nType+i]))^,2);
end;
Listtmp.SubItems.Add('0x'+ LhbStr);
Listtmp.SubItems.Add('量化表表项');
Listtmp.SubItems.Add('DQT(Difine Quantization Table)');
end;
158:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('帧图像开始');
Listtmp.SubItems.Add('SOF0(Start of Frame)');
end;
160:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('帧图像总长度');
Listtmp.SubItems.Add('SOFL(start of frame length)');
end;
162:begin
Listtmp.SubItems.Add(IntToHex(nType-2,2));
Listtmp.SubItems.Add('1字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('精度(precision),每个颜色分量每个像素的位数');
Listtmp.SubItems.Add('bits per pixel per color component');
end;
163:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('图像高度');
Listtmp.SubItems.Add('image height');
end;
165:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('2字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('图像宽度');
Listtmp.SubItems.Add('image width');
end;
167:begin
Listtmp.SubItems.Add(IntToHex(nType-2,4));
Listtmp.SubItems.Add('1字节');
Listtmp.SubItems.Add('0x'+ s);
Listtmp.SubItems.Add('颜色分量数');
Listtmp.SubItems.Add('number of color components');
Listtmp.SubItems.Add('灰度图是 1, YCbCr/YIQ 彩色图是 3, CMYK 彩色图是 4,我们这里讨论的JFIF使用的是YCbCr,故这里颜色分量数为3');
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
PicDataLen:Integer ;
i,j,k,m,n:Integer ;
//NewPicDataArray:array of Byte ;
sWord:Word ;
QTLLen:Word ;//量化表长度
begin
PicDataLen :=High(PicDataArray);
SetLength(NewPicDataArray,PicDataLen +1);
if PicDataLen>0 then
begin
for i:=0 to PicDataLen-1 do
begin
//ZeroMemory(@NewPicDataArray,PicDataLen );
CopyMemory(@NewPicDataArray[i],@PicDataArray[i],1);
end;
end;
ListView1.Clear ;
n:=0;
//m:=0;
for j:=0 to High(NewPicDataArray)-1 do
begin
case j of
0:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
2:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
4:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
6:AddListView(GetPiCData(@NewPicDataArray[j],1)+
GetPiCData(@NewPicDataArray[j+1],2)+GetPiCData(@NewPicDataArray[j+3],2),j);
11:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
13:begin
case Pbyte(DWORD(@NewPicDataArray[j]))^ of
0:AddListView('无',j);
1:AddListView('点数/英寸',j);
2:AddListView('点数/厘米',j);
end;
end;
14:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
16:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
18:AddListView(GetPiCData(@NewPicDataArray[j],1),j);
19:AddListView(GetPiCData(@NewPicDataArray[j],1),j);
20:begin //取量化表个数
//if (Pbyte(DWORD(@NewPicDataArray[j-2]))^ =0) and (Pbyte(DWORD(@NewPicDataArray[j-1]))^ =0) then
//ShowMessage('无缩略图RGB位图'); //判断有无缩略图RGB位图
AddListView(GetPiCData(@NewPicDataArray[j],2),j) ;
m:=j;
for k:=m to High(NewPicDataArray)-j-1 do
begin
sWord := Pword(DWORD(@NewPicDataArray[m]))^;
QTLLen :=Pword(DWORD(@NewPicDataArray[m+2]))^;
WordLoHiExchange(QTLLen);
WordLoHiExchange(sWord);
if sWord= StrToInt('$'+'FFDB') then
begin
n:=n+1;
m:=m+ Integer( QTLLen)+2 ;
end else
Break ;
end;
//ShowMessage('有量化表:'+ IntToStr(n)+'个');
end;
22:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
24:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
25:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
89:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
91:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
93:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
94:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
158:AddListView(GetPiCData(@NewPicDataArray[j],2),j); //2字节 0xFFC0
160:AddListView(GetPiCData(@NewPicDataArray[j],2),j); //2字节 帧图像数据长度
162:AddListView(GetPiCData(@NewPicDataArray[j],1),j);
163:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
165:AddListView(GetPiCData(@NewPicDataArray[j],2),j);
167:AddListView(GetPiCData(@NewPicDataArray[j],1),j);
end;
end;
end; |
|