Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - GDI, Drawing an Image
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

GDI, Drawing an Image

 Post Reply Post Reply
Author
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Topic: GDI, Drawing an Image
    Posted: 16 October 2004 at 9:32am

Hey guys, I am working on a simple GDI Script in SharePoint. This is only Code Behind. I am trying to write the stream. I have two errors. It is saying Response is not declared. Is there any other way to declare this... Can I import something that might fix the problem.

Response.ContentType = "image/gif"
fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif) 

Please Advise, Thank you...

Shrini

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2004 at 10:57am
Imports HTTPCOntext.Current
at the top of the Code behind page.
Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2004 at 11:57am

Michael you are a genius...

It worked perfect with a little hitch..

As per your advise, I imporeted System.web.httpcontext and changed my response to current.response.

Now for what's happening and the little bit code:

myImage = New Image
Controls.Add(myImage)
myImage.ImageURL = WriteGDI(passing Values)

function WriteGDI()
...............................
...............................
    myBitMap.Save(memStream, ImageFormat.Png)
    memStream.WriteTo(Current.Response.OutputStream)
End Function

What this is doing is replacing my page with the image itself. What can I do to just have the image change in the middle of the page.

Thanks a lot for take time to assist me.
Shrini

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2004 at 1:50pm
Not sure what you mean with just replacing the middle of the page. If you want to display a gdi image within another page you either need to add a placeholder or image control to the page and then dynamically add the .aspx as gdi to it. Generating a gdi image will result in the aspx page to be an image so you need to add it to another page.
Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2004 at 7:00pm

Michael,

I already have a place holder for the image in the middle of the page.

I have a function I am passing the information to the Funciton which which generates a simple image. There are no other ASPX pages where I can move the Script and pass the values through QueryString to the page.

It looks like I am screwed in a manner.

Hope there is a solution.

Shrini

Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2004 at 7:57pm

Michael,

Here is an interesting option. May Be!

I can serialize the image. Can I deserialize it and assign it as the imageURL.

Don't know how I can do that yet and is it going to drop me in the same position.

Shrini

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2004 at 8:20pm
If you do not want to generate the image in a 2nd page so you can set the URL you will need to use a HTTP Handler. This is once you understand HTTP Handlers fairly easy to do, here is a c# example how the asp.net forums generate an avatar which is passes as a binary from database

using System;
using System.Web;
using System.Web.Caching;
using AspNetForums;

namespace AspNetForums.Components.HttpHandler {

    public class AvatarHttpHandler : IHttpHandler {

        public void ProcessRequest (HttpContext context) {

             try {
                Avatar userAvatar = Resources.GetAvatar( int.Parse(context.Request.QueryString["UserID"]) );

                context.Response.ContentType = userAvatar.ContentType;
                context.Response.OutputStream.Write(userAvatar.Content, 0, userAvatar.Length);

                context.Response.Cache.SetCacheability(HttpCacheability.Publ ic);
                                     context.Response.Cache.SetExpires(DateTime.Now.AddMinutes(30));
                context.Response.Cache.SetAllowResponseInBrowserHistory(true );
                context.Response.Cache.SetValidUntilExpires(true);
                context.Response.Cache.VaryByParams["UserID"] = true;
             } catch {}

        }

        public bool IsReusable {
             get {
                return false;
             }
        }
    }
}
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.