I've got a small sockets application where I communicate with a web server
via async sockets method.
Using the ASCIIEncoding Class, I convert strings to byte arrays (and vice
versa) in conjunction with beginSend and beginReceive (and their
corresponding callbacks). So long as the web server and I just deal in
text, life is easy.
Now there's an image I want to request and then display in my app, it's a
dynamic PNG image that's generated by some .aspx page on the web server. So
my GET, to request this image, looks like this:
GET /MakeThePNG.aspx HTTP/1.1
Host: www.url.com
And here's the website's response:
HTTP/1.1 200 OK
Date: Thu, 01 Dec 2005 20:28:01 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Transfer-Encoding: chunked
Cache-Control: private, max-age=1800
Content-Type: image/png
39c9
?PNG
<a bunch of data>
0
I need to turn this response (sans the header, I'm assuming, but I'm unsure
which portions of the body) into an image object that I can display in a
picture box & save to disk. I've tried messing around with a Memory Stream,
and with that, tried including the whole body portion, just the <a bunch of
data> portion, but my attempts thus far are ultimately met with an Invalid
Argument exception when I try to make a new Image.FromStrea m with my Memory
Stream. I've tried to save said portions of the buffer to disk, but it does
not make a valid png file. So I'm not carving the data out of the body
correctly, or, it's not encoded correctly, or... ? I'm stumped. 2 2086
Ok, the answer was to read up on how PNGs are put together. http://www.w3.org/TR/PNG/
PNGs start with with 8 "signature" bytes, 137 80 78 71 13 10 26 10. Those
are the first 8 bytes of the PNG file.
PNGs end with an "IEND" chunk, literally "IEND" (73 69 78 68), followed by 4
more bytes (CRC portion of the chunk). Those are the last 8 bytes of the
PNG file.
As soon as I exctracted the bytes from the Signature to the IEND chunk
(inclusive) and fed it to a memory stream, thus correctly carving out the
whole PNG file and nothing but the PNG file, Image.FromStrea m magically
turned the memory stream into an image.
"1388-2/HB" <1@1.net> wrote in message
news:43******** **************@ news.usenetmons ter.com... I've got a small sockets application where I communicate with a web server via async sockets method.
Using the ASCIIEncoding Class, I convert strings to byte arrays (and vice versa) in conjunction with beginSend and beginReceive (and their corresponding callbacks). So long as the web server and I just deal in text, life is easy.
Now there's an image I want to request and then display in my app, it's a dynamic PNG image that's generated by some .aspx page on the web server. So my GET, to request this image, looks like this:
GET /MakeThePNG.aspx HTTP/1.1 Host: www.url.com
And here's the website's response:
HTTP/1.1 200 OK Date: Thu, 01 Dec 2005 20:28:01 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Transfer-Encoding: chunked Cache-Control: private, max-age=1800 Content-Type: image/png
39c9 ?PNG <a bunch of data> 0
I need to turn this response (sans the header, I'm assuming, but I'm unsure which portions of the body) into an image object that I can display in a picture box & save to disk. I've tried messing around with a Memory Stream, and with that, tried including the whole body portion, just the <a bunch of data> portion, but my attempts thus far are ultimately met with an Invalid Argument exception when I try to make a new Image.FromStrea m with my Memory Stream. I've tried to save said portions of the buffer to disk, but it does not make a valid png file. So I'm not carving the data out of the body correctly, or, it's not encoded correctly, or... ? I'm stumped.
why dont you just use a HTTP stream and read it as binary?! its so much
easier
"1388-2/HB" <1@1.net> wrote in message
news:43******** **************@ news.usenetmons ter.com... Ok, the answer was to read up on how PNGs are put together.
http://www.w3.org/TR/PNG/
PNGs start with with 8 "signature" bytes, 137 80 78 71 13 10 26 10. Those are the first 8 bytes of the PNG file.
PNGs end with an "IEND" chunk, literally "IEND" (73 69 78 68), followed by 4 more bytes (CRC portion of the chunk). Those are the last 8 bytes of the PNG file.
As soon as I exctracted the bytes from the Signature to the IEND chunk (inclusive) and fed it to a memory stream, thus correctly carving out the whole PNG file and nothing but the PNG file, Image.FromStrea m magically turned the memory stream into an image.
"1388-2/HB" <1@1.net> wrote in message news:43******** **************@ news.usenetmons ter.com... I've got a small sockets application where I communicate with a web server via async sockets method.
Using the ASCIIEncoding Class, I convert strings to byte arrays (and vice versa) in conjunction with beginSend and beginReceive (and their corresponding callbacks). So long as the web server and I just deal in text, life is easy.
Now there's an image I want to request and then display in my app, it's a dynamic PNG image that's generated by some .aspx page on the web server. So my GET, to request this image, looks like this:
GET /MakeThePNG.aspx HTTP/1.1 Host: www.url.com
And here's the website's response:
HTTP/1.1 200 OK Date: Thu, 01 Dec 2005 20:28:01 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Transfer-Encoding: chunked Cache-Control: private, max-age=1800 Content-Type: image/png
39c9 ?PNG <a bunch of data> 0
I need to turn this response (sans the header, I'm assuming, but I'm unsure which portions of the body) into an image object that I can display in a picture box & save to disk. I've tried messing around with a Memory Stream, and with that, tried including the whole body portion, just the <a bunch of data> portion, but my attempts thus far are ultimately met with an Invalid Argument exception when I try to make a new Image.FromStrea m with my Memory Stream. I've tried to save said portions of the buffer to disk, but it does not make a valid png file. So I'm not carving the data out of the body correctly, or, it's not encoded correctly, or... ? I'm stumped.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: OneSolution |
last post by:
Hi All,
Here's what I'm trying to do.
I have a diverse customer base, and as it grows, it's increasingly harder to
figure out what aspect of our web site is selling and what is not. So I've
been trying to use PHP (and/or ASP) to do some research on my customers. So
I nosed around some web sites and found the following piece of code.
<IMG
|
by: yawnmoth |
last post by:
i've written a php script that generates images dynamically, via the
GD library. i now want to detect whether or not the image is embedded
within a homepage, or is being viewed by itself. at first, i thought
that whether or not HTTP_SERVER_VARS was set, that it would
mean that the image was embedded, but that's not necessarily the case,
as it will also be set if it's just linked to from the webpage. so,
any ideas?
|
by: Suzanne Boyle |
last post by:
I have the following code in a webpage:
<p><img src="images/clydesdale.gif" width="100" height="41" style="float:
left;" />
<strong>Test</strong><br />
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et
justo duo dolores et ea rebum. <br />
visit website
|
by: Chris Dewin |
last post by:
Hi. I run a website for my band, and the other guys want an image gallery.
I'm thinking it would be nice and easy, if we could just upload a jpg into
a dir called "gallery/". When the client clicks the "gallery" link, a
cgi script could search the gallery/ dir, and create thumbnails of any
jpeg images that don't already have a thumbnail associated with them. The
script could then generate a page of clickable thumbnails.
A few questions:
|
by: lkrubner |
last post by:
Suppose I need to get an image as a stream of bytes. I want to store
this in a variable and then embed it in some Postscript code. In my
Postscript code, the image might look like this:
{<
ffffffffffffffffffffffffffffffffffffffffffffffffffff
ff000000000000000000000000000000000000ffffffffffffff
ff00efefefefefefefefefefefefefefefef0000ffffffffffff
ff00efefefefefefefefefefefefefefefef00ce00ffffffffff
| |
by: Geert |
last post by:
Hi all,
I have a webservice that creates an image. I want to show the result of that
image on my website. The website and webservice are on different servers.
There is a VPN line between both servers.
What is the best way to sent the image to my website?
- save the file on a share
- sent a stream from the webservice to the site (if it is possible to do)
- save the file to http://websiteserver/tempfolder (if possible)
|
by: rh1200la |
last post by:
Hey all. I need to output an image via an .aspx page and hope someone
here can help.
I would like to display an image like this:
<img src="displayImage.aspx?categoryID=1">
The .aspx page will grab a random URL from the database based on the
category id.
I would like the script to load the URL and download the image, and
|
by: =?Utf-8?B?TWlrZQ==?= |
last post by:
Hi. I have an ASP.NET 2.0 web application which contains an Images directory
with all website images. How can I prevent other websites from creating img
tags with the source as my images? I want to prevent other websites from
serving my image.
For example - How can I prevent another website from doing this?
<img src="http://mywebsitename/images/image1.jpg"
Is this possible? Thanks
|
by: lawpoop |
last post by:
I'm developing a php website that I have under subversion version
control. I'm working on an image upload functionality, and in the
middle of it I realized that any files that a user uploads will not be
under version control, and if I checkout or export the site from
version control, and deploy it, it won't bring any of the uploaded
files with it.
I'm looking at php subversion functions, but the manual says that
they're experimental,...
|
by: jeddiki |
last post by:
Hi,
I am giving cleints an image to use as a kind of "trust seal" and I want
to record the number of times it is diplayed, is that possible with
php, of is this a javascript project ?
This is what I mean:
I will give a client this code to place on their website:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |