Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Mobile / October 2004

Tip: Looking for answers? Try searching our database.

Server-side image creation in ASP.NET Mobile Web Application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RicardoVeloso - 20 Oct 2004 11:31 GMT
Hi,

I have to generate an image based on information saved in a DB.
This image needs to contain the draw of a cinema room places. This work has
the objective to implement a Online cinema ticket reservation.

I try this:
Bitmap bitmap = new Bitmap(10,10);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
           
g.DrawLine(new Pen(Color.BurlyWood), 0, 0, 10, 10);

bitmap.Save("image1.png", System.Drawing.Imaging.ImageFormat.Png);
Image1.ImageUrl = Server.MapPath(Session.SessionID + ".png");

But the Save method is not available  in .NETCF, and I don't know if this is
the best way to force an image to be visible on the client-side.

Any help to turn around this problem?

Thanx a lot,
Ricardo Veloso
Ted Harper - 21 Oct 2004 06:38 GMT
>I try this:
>Bitmap bitmap = new Bitmap(10,10);
[quoted text clipped - 7 lines]
>But the Save method is not available  in .NETCF, and I don't know if this is
>the best way to force an image to be visible on the client-side.

If you are creating the image on the server side as your post says,
then you shouldn't be worred about what the Compact Framework does or
doesn't support, since the image-generation code is NOT running on the
handheld device. In your web server code (running under the full .Net
Framework) you will be doing more-or-less the same to target a mobile
browser as a "full featured" desktop PC browser.

That is, on the web server you will have a SomeDynamicImage.aspx page
which actually returns a GIF or JPEG image, and you will reference
that inside a mobile image control as something like:

<mobile:Image ID="imgRiskChart" Runat="server"
ImageUrl="SomeDynamicImage.aspx"></mobile:Image>

There are a few things to be careful of when writing this dynamic
image to support mobile devices (and I am assuming you already have
the equivalent dynamic image creation working for full desktop
browsers - if not I highly recommend you do this first, just for ease
of debugging your overall chart creation code):

* You should extend System.Web.UI.Page (rather than MobilePage) for
your dynamic image ASPX, to avoid it being attempted to be processed
by the ASP.Net Mobile framework (which doesn't understand a page
having an image MIME type).

* Your calling page (ie the page with the mobile:image tag referencing
the dynamic image) will need to pass in the image size (X/Y
dimenstions), colour depth, preferred MIME type for output image (eg
GIF, JPG, WBMP), and do this dynamically in the codebehind for each
request, because all handheld devices are different.

* When building/updating the ImageUrl in the mobile:Image control,
you'll also have to manually append the authentication cookie if you
are using forms authentication and cookieless (as you'll probably have
to for good wide mobile device support), since this won't be affixed
to the ImageURL automatically by the framework (and if you don't, the
framework will redirect the image content to the logon page, rather
than your rendering code getting run).

Aside from that stuff, you _should_ be able to get your existing
(non-Mobile) ASP.Net dynamic chart/image code working for mobile
clients pretty quickly.

Hope this helps,
ted.h.
Signature

Ted Harper (Sydney, Australia)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.