Как на сайте програмно узнать jpeg картинка или png, в снифере формат картинки стоит в Content-Type из Response Headers , но как прочитать из него не нашёл инфы:( Тут на форуме нашёл Код | function PhysicalResolveFileType(AStream: TStream): Integer; var p: PChar; begin Result := 0; if not Assigned(AStream) then Exit; GetMem(p, 10); try AStream.Position := 0; AStream.Read(p[0], 10); {bitmap format} if (p[0] = #66) and (p[1] = #77) then Result := 1; {tiff format} if ((p[0] = #73) and (p[1] = #73) and (p[2] = #42) and (p[3] = #0)) or ((p[0] = #77) and (p[1] = #77) and (p[2] = #42) and (p[3] = #0)) then Result := 2; {jpg format} if (p[6] = #74) and (p[7] = #70) and (p[8] = #73) and (p[9] = #70) then Result := 3; {png format} if (p[0] = #137) and (p[1] = #80) and (p[2] = #78) and (p[3] = #71) and (p[4] = #13) and (p[5] = #10) and (p[6] = #26) and (p[7] = #10) then Result := 4; {dcx format} if (p[0] = #177) and (p[1] = #104) and (p[2] = #222) and (p[3] = #58) then Result := 5; {pcx format} if p[0] = #10 then Result := 6; {emf format} if (p[0] = #215) and (p[1] = #205) and (p[2] = #198) and (p[3] = #154) then Result := 7; {emf format} if (p[0] = #1) and (p[1] = #0) and (p[2] = #0) and (p[3] = #0) then Result := 7; finally Freemem(p); end; end;
|
и где-то в сети как её использовать Код | procedure TForm1.Button1Click(Sender: TObject); var fs: TFileStream; begin fs := TFileStream.Create( 'C:\test.bmp', fmOpenRead ); case PhysicalResolveFileType( fs ) of 1: Caption := 'BMP'; 2: Caption := 'TIFF'; 3: Caption := 'JPG'; 4: Caption := 'PNG'; 5: Caption := 'DCX'; 6: Caption := 'PCX'; 7: Caption := 'EMF'; 8: Caption := 'TGA'; 9: Caption := 'ICO'; 10: Caption := 'GIF'; end; fs.Free; end;
|
Правда пример не чего не показывает да и как привязать его к своей задачи Код | procedure BOT.capcha; var inf:TStringList; img: TMemoryStream; png: TPNGObject; begin inf:=tstringlist.create; img:=TMemoryStream.Create; HTTP_BUX.get('http://' + Url_Pay +'image.php?',img); img.Position:=0; png:= TPNGObject.Create; png.LoadFromStream(img); Form2.Image1.Picture.Assign(png); png.Free; img.Free; Form2.Edit1.Text:= ''; Form2.show; try Suspended:=true; inf.Add('username=' +Login); inf.Add('password=' +Pass); inf.Add('code=' + Form9.Edit1.Text); finally inf.Free; end; end;
|
непойму:( Это сообщение отредактировал(а) gex5293 - 27.11.2010, 10:07
|