Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
FPHttpServer provide .png files
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
DataPort or Synpase stat...
by
serbod
[
Today
at 09:30:51 am]
SynEdit auto End of line ...
by
Martin_fr
[
Today
at 09:08:36 am]
Show Case: WritingTool
by
ginoo
[
Today
at 08:47:02 am]
TComboBoxEx & TCheckCombo...
by
pmralbuquerque
[
Today
at 07:31:59 am]
How to view the TODO list...
by
Thaddy
[
Today
at 07:16:27 am]
Application.QueueAsyncCal...
by
Thaddy
[
Today
at 06:26:12 am]
Scripts to generate ofici...
by
dbannon
[
Today
at 02:25:56 am]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[
Today
at 01:20:44 am]
FPC Unleashed (inline var...
by
440bx
[
Today
at 12:55:44 am]
International Pascal Cong...
by
Mike.Cornflake
[May 09, 2026, 06:45:37 pm]
SpreadSheet Add Chart Lin...
by
eldonfsr
[May 09, 2026, 06:19:33 pm]
How do 'with' statements ...
by
Thaddy
[May 09, 2026, 05:48:50 pm]
How to access inherited m...
by
Thaddy
[May 09, 2026, 04:12:38 pm]
Anubis activated
by
LemonParty
[May 09, 2026, 03:46:01 pm]
RunFormula: math expressi...
by
LeP
[May 09, 2026, 03:39:53 pm]
Setting canvas offset wit...
by
jamie
[May 09, 2026, 03:14:04 pm]
Limiting Search in TSelec...
by
jamie
[May 09, 2026, 03:09:21 pm]
using make with a differe...
by
Thausand
[May 09, 2026, 02:41:39 pm]
FreeBSD 13/14: RTL dirent...
by
Fred vS
[May 09, 2026, 02:33:11 pm]
Problems with form.AutoSc...
by
OH1KH
[May 09, 2026, 12:07:44 pm]
AVRPascal – free code edi...
by
ackarwow
[May 09, 2026, 09:23:14 am]
Can /my/ AI help me with ...
by
valdir.marcos
[May 09, 2026, 08:34:18 am]
Laz program on ChromeOS?
by
Thaddy
[May 09, 2026, 07:58:21 am]
Gtk3 widgetset - call for...
by
dbannon
[May 09, 2026, 03:23:51 am]
Is it timing of a dataset...
by
egsuh
[May 09, 2026, 02:46:11 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: FPHttpServer provide .png files (Read 908 times)
anderbelluno
New Member
Posts: 44
FPHttpServer provide .png files
«
on:
April 07, 2023, 03:56:36 pm »
Hey guys.
I need to provide .png files using FPHTTPServer, I can't find much on the subject.
I'm studying the possibilities, to later improve the codes.
Note: these are tests.
Code: Pascal
[Select]
[+]
[-]
class
procedure
TLib
.
LoadImg
(
var
aStream
:
TMemoryStream
)
;
var
xFile
:
TMemoryStream
;
begin
xFile
:
=
nil
;
xFile
:
=
TMemoryStream
.
Create
;
try
xFile
.
LoadFromFile
(
'C:\Users\anderson\Desktop\Lazarus\FPHTTP\Server\img.png'
)
;
xFile
.
Position
:
=
0
;
xFile
.
SaveToStream
(
aStream
)
;
finally
FreeAndNil
(
xFile
)
;
end
;
end
;
This procedure reads the file...
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
FPHttpServer1Request
(
Sender
:
TObject
;
var
ARequest
:
TFPHTTPConnectionRequest
;
var
AResponse
:
TFPHTTPConnectionResponse
)
;
var
xStream
:
TMemoryStream
;
begin
xStream
:
=
TMemoryStream
.
Create
;
try
TLib
.
LoadImg
(
xStream
)
;
xStream
.
Position
:
=
0
;
xStream
.
SaveToStream
(
AResponse
.
ContentStream
)
;
AResponse
.
ContentType
:
=
'image/png'
;
//; charset=utf-8
finally
FreeAndNil
(
xStream
)
;
end
;
end
;
This is the FPHTTPServer's onRequest.
But the image that is returned is not correct.
What am I doing wrong?
Thanks.
Logged
Leledumbo
Hero Member
Posts: 8836
Programming + Glam Metal + Tae Kwon Do = Me
Re: FPHttpServer provide .png files
«
Reply #1 on:
April 07, 2023, 05:32:00 pm »
Though I don't know why you want to
reinvent the wheel
, you can take a look at
how it's done
.
Logged
Follow this if you want me to answer:
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
http://pascalgeek.blogspot.com
https://bitbucket.org/leledumbo
https://github.com/leledumbo
Code first, think later - Natural programmer B)
anderbelluno
New Member
Posts: 44
Re: FPHttpServer provide .png files
«
Reply #2 on:
April 07, 2023, 10:05:58 pm »
Excuse my ignorance my friend, I never wanted to reinvent the wheel, I'm simply learning to use the component, so I'm making mistakes and learning.
Thanks a lot for your help, it worked great.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
FPHttpServer provide .png files
TinyPortal
© 2005-2018