Вниз
Скачать: 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.46 MB
Время: 0.012 c
1-24423
Karburator
2003-08-25 21:21
2003.09.08
Отличие файла от каталога


14-24699
ZeroDivide
2003-08-18 09:35
2003.09.08
SoftIce


14-24625
alxx
2003-08-21 17:11
2003.09.08
Технология Клиент-Сервер


14-24653
LordOfSilence
2003-08-20 15:30
2003.09.08
Ищу компаньон(а/ов) :-)


9-24291
DeadMeat
2003-02-14 20:21
2003.09.08
GLScene и анимация...




   Наверх