Вниз
Скачать: CL | DM;

Indy HTTP server   Найти похожие ветки 

← →
ASTARD   (2003-06-30 19:21) [0]

Не подскажите как сделать так что бы вместе с текстом ХТМЛ уходили клиенту (Internet Explorer) и картинки прописаные в этом ХТМЛ(<IMG SRC=>)? Иван. Спасибо!!!


← →
AL_!   (2003-07-01 02:50) [1]

LOL !... :)


← →
vidiv ©   (2003-07-01 07:39) [2]

Я бы написал сюда код программы которая по inHTTPServer посылает картинку, но ведь модераторы замодерят код, но часть его пожалуйста:

procedure TForm1.HTTPSerCommandGet(AThread: TIdPeerThread;
RequestInfo: TIdHTTPRequestInfo; ResponseInfo: TIdHTTPResponseInfo);
var s:TMemoryStream; b:Tbitmap; dc:hdc;
jpg:TJPEGImage;
q:integer;
begin
log(Request: "+RequestInfo.Command+"; "+RequestInfo.RemoteIP);
if CheckAuth.Checked and (
(not RequestInfo.AuthExists) or
(RequestInfo.AuthUsername<>AuthLogin.Text) or
(RequestInfo.AuthPassword<>AuthPasswd.Text) ) then
begin
log("Auth!");
ResponseInfo.ContentType := "text/html";
ResponseInfo.AuthRealm := authtext.Text;
ResponseInfo.ContentText := "<html><body><font size=5>Vid Internet Screen Viewer</font><br><font size=4 color=red> Auth Needed!</font></body></html>";
ResponseInfo.WriteHeader;
ResponseInfo.WriteContent;
exit;
end;
if uppercase(RequestInfo.Document)="/IMG" then
begin
b:=TBitmap.Create;
b.Width := Screen.Width;
b.Height := Screen.Height;
jpg := TJPEGImage.Create;
dc:=getdc(0);
BitBlt(b.Canvas.Handle,0,0,b.Width,b.Height,dc,0,0,SRCCOPY);
DeleteDC(dc);
jpg.Assign(b);
b.free;
q := StrToIntDef(RequestInfo.Params.Values["q"],TrackBar1.Position);
if not (q in [1..100]) then q:=TrackBar1.Position;
jpg.CompressionQuality := q;
jpg.Compress;
ResponseInfo.ContentStream:=TMemoryStream.Create;
jpg.SaveToStream(ResponseInfo.ContentStream);
jpg.Free;
ResponseInfo.ContentType := "image/jpeg";
end else
begin
ResponseInfo.ContentType := "text/html";
q := StrToIntDef(RequestInfo.Params.Values["q"],TrackBar1.Position);
if not (q in [1..100]) then q:=TrackBar1.Position;
ResponseInfo.ContentText := "<html><title>Vid Internet Screen Viewer</title><body>"+
( q)
Я бы написал сюда код программы которая по inHTTPServer посылает картинку, но ведь модераторы замодерят код, но часть его пожалуйста:

procedure TForm1.HTTPSerCommandGet(AThread: TIdPeerThread;
RequestInfo: TIdHTTPRequestInfo; ResponseInfo: TIdHTTPResponseInfo);
var s:TMemoryStream; b:Tbitmap; dc:hdc;
jpg:TJPEGImage;
q:integer;
begin
log(Request: "+RequestInfo.Command+"; "+RequestInfo.RemoteIP);
if CheckAuth.Checked and (
(not RequestInfo.AuthExists) or
(RequestInfo.AuthUsername<>AuthLogin.Text) or
(RequestInfo.AuthPassword<>AuthPasswd.Text) ) then
begin
log("Auth!");
ResponseInfo.ContentType := "text/html";
ResponseInfo.AuthRealm := authtext.Text;
ResponseInfo.ContentText := "<html><body><font size=5>Vid Internet Screen Viewer</font><br><font size=4 color=red> Auth Needed!</font></body></html>";
ResponseInfo.WriteHeader;
ResponseInfo.WriteContent;
exit;
end;
if uppercase(RequestInfo.Document)="/IMG" then
begin
b:=TBitmap.Create;
b.Width := Screen.Width;
b.Height := Screen.Height;
jpg := TJPEGImage.Create;
dc:=getdc(0);
BitBlt(b.Canvas.Handle,0,0,b.Width,b.Height,dc,0,0,SRCCOPY);
DeleteDC(dc);
jpg.Assign(b);
b.free;
q := StrToIntDef(RequestInfo.Params.Values["q"],TrackBar1.Position);
if not (q in [1..100]) then q:=TrackBar1.Position;
jpg.CompressionQuality := q;
jpg.Compress;
ResponseInfo.ContentStream:=TMemoryStream.Create;
jpg.SaveToStream(ResponseInfo.ContentStream);
jpg.Free;
ResponseInfo.ContentType := "image/jpeg";
end else
begin
ResponseInfo.ContentType := "text/html";
q := StrToIntDef(RequestInfo.Params.Values["q"],TrackBar1.Position);
if not (q in [1..100]) then q:=TrackBar1.Position;
ResponseInfo.ContentText := "<html><title>Vid Internet Screen Viewer</title><body>"+
"Quality: "+inttostr(q)+"%<br><img name="ab" src="img?q="+RequestInfo.Params.Values["q"]+"&tmp="+inttostr(random(maxint))+""></body></html>"
end;
end;


uses jpeg; не забудь


← →
Gigabyte ©   (2003-07-02 21:15) [3]

Когда я использовал TIdHTTPServer. Он у меня без всяких этих кодов сам автоматически пересылал картинки. Все, что ему требовалось, это открыть картинку и передать ее в поток. посредстром TStream.CopyFrom(). И больше никаких ухищрений типа

b:=TBitmap.Create;
b.Width := Screen.Width;
b.Height := Screen.Height;
jpg := TJPEGImage.Create;
dc:=getdc(0);
BitBlt(b.Canvas.Handle,0,0,b.Width,b.Height,dc,0,0,SRCCOPY);
DeleteDC(dc);
jpg.Assign(b);
b.free;
q := StrToIntDef(RequestInfo.Params.Values["q"],TrackBar1.Position);
if not (q in [1..100]) then q:=TrackBar1.Position;
jpg.CompressionQuality := q;
jpg.Compress;
ResponseInfo.ContentStream:=TMemoryStream.Create;
jpg.SaveToStream(ResponseInfo.ContentStream);
jpg.Free;
ResponseInfo.ContentType := "image/jpeg";

Я не использовал. И РАБОТАЕТ!



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: -0.964 c
8-24564
wara
2003-05-12 11:35
2003.09.08
Какие данные хранятся вместе с графикой в графических файлах?


14-24674
NAlexey
2003-08-20 09:33
2003.09.08
Фень Юань?


11-24402
Ajax
2003-01-01 19:15
2003.09.08
Скриншот из программы


6-24585
MGA
2003-05-05 18:37
2003.09.08
Контроль печати сетевого принтера - КАК ?


6-24572
alak
2003-06-30 10:00
2003.09.08
Pagecontrol and webbrowser




   Наверх