Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Images in designer

  Asked By: Joao    Date: Jun 17    Category: Asp.net    Views: 1116
  

I have my designer attached to my web control and I can get it to dish out html at design time. Fab.
I want to be jazzy and have an image representation, a logo appear when the control is dragged from the toolbox onto a page.

I can get it to take an image via an url .... but I want to embedd that image into resources so it doesn't have to be supplied seperately.

Problem.

All standard html asp controls I can find to render to the designer need an image in the form of an url ... usually control.ImageUrl.
And the asp control, System.Web.UI.WebControls.Image, itself needs an url.

I don't have an url ... I have a bitmap.
I got it by embedding and rebuilding and using
System.Drawing.Bitmap im = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("developalogo.bmp"));
and can change it to a drawing image like
System.Drawing.Image im2 = (System.Drawing.Image)im;

So I need to
(a) figure a way to pump that bitmap down the url stream. I can get an <img> html tag to accept a aspx page as a source (src="genimage.aspx") .... because the aspx page saves the image to output stream.
Can I trick the ImageUrl property of web controls into accepting an ImageStream of some sort ???

(b) find a html rendering control that I can use a bitmap with ..... and there isn't one. So this leads to the path of making a control that I can paint using the bitmap.
Can I do this ??????? at the end of the day the designer uses control.RenderControl(writer); to spit out html to the designer - so if I go and make a control I'll have to build it from other exisiting web controls and again, I'll have the problem of the url being required.

Maybe I can overidde the paint of an existing aspnet web server control ? can I do that ???? I doubt it.

Basically I need to paint a web control ... but not for the web simply for the VS.NET designer.
I cannot make a Winforms control, paint it and use that to import to designer - because it has to render as html.

There are resources examples in "HowTo" and in "Tutorials" but, when dealing with WinForms, you ultimately end up with a Sytem.Drawing.Image.
There is only one example of using resources with asp.NET and that merely pulls a string from resources and puts it in a image src tag - so it's not using the image from resources at all - just a string from the resources.

Which takes me back to the idea of an aspx page being used as a src for an image.

Is there any way I can hoodwink a System.Web.UI.WebControls.Image into taking some version of my bitmap as it's url, using a stream of some kind.
(I tried
System.Web.UI.WebControls.Image im3;
im3.ImageUrl = im2.Save(HttpContext.Current.Response.OutputStream, ImageFormat.Jpeg) ..... but it was never going to work from the start .... but it's got to be similar.


Can anyone enlighten me, please, please, please.
If you don't want to let on then please can someone just tell me if it can be done and I'll (eventually) figure it myself.

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Maria Miller     Answered On: Jun 17

1) I've read you can create a HttpModule(HttpHandler?) that will stream  an image  as you wish. But then your going way beyond just one control. And that's not design  time.

2) There's a "Image to HTML" sample on:

www.gotdotnet.com/.../keywordsrch.aspx%20Server%20Control

It's as slow as Forrest Gump on a bad day, but might give you what you want in the designer.

3) Overall.....I recommend saving the image to a file and setting the URL.

4) "If you don't want to let on then please  can someone just tell me if it can be done and I'll (eventually) figure  it myself."

That line strikes a chord. Seems to me that MS and all the "insiders" are hording information on NET. Trying to find  anything beyond the basics is next to impossible unless you can afford an MSDN subscription or the 50 bucks each for a series of 500+ books written by current/former MS employees or MVPs. And even then, the info is skimpy. I'm troubled that I can honestly say-- I've learned more with a de-compiler I downloaded, than anything else.

 
Answer #2    Answered By: Elias Turner     Answered On: Jun 17

Yes, it is possible to do this. In fact it is on my to-do list.
It requires writing an HttpHandler that will accept  querystring
parameters and returning the formatted images  to a control. I have a book
which demonstrates this but it hasn't been a high priority to make
an image control  or ImageButton which can use this functionality.
I'll attach some files and send them to your personal email address.

 
Answer #3    Answered By: Kifah Malik     Answered On: Jun 17

What this effectively means now (I think) is that we can wrap up images  in resource assemblies and access them as urls (with a bit of work)

I can't thank you enough, that ones been in the back  of my mind for a long long time.

Will keep an eye open for httphandlers/info from now on.

And your right about info, at the sort  of level I'm getting to the info's getting scarcer. I have 1Gb of MSDN.NET on my pc's and it's just a load of definitive, shallow, brush over the surface hogwash which you cannot understand unless it's strung together in some sort of example  so you can see how it works. I keep expecting examples  but there's hardly any .... streams is a good one, lots of definitions and loads of members but how the bollox do you use them ????
Oh .... and the only wishy washy examples in framwork are for FileStream - every bl**dy one of them, I want a mem stream  - and a mem font aswell.

I mean - take a look at Assembly.GetExecutingAssembly().GetManifestResourceStream("developalogo.bmp");

Would anyone ever think of looking at Assembly to get to an image  ???? I'd never even heard of it till that turned up. You can imaging trying to figure  out how to use that from MSDN, you know, if someone said - oh yes, use Assembly. You'de be there till your hair fell out trying to find  it.

If I had the money it's about now I'd go out and buy meslef a great big, thick, fat, expensive book, that would put the bible to shame.

Till that day, I'll keep on foreaging around for snippets worthy of my attention.

What decompiler did you get - wasn't ummmm, anakrino was it ? I want one that spit sit all out into a file ... all of the freebies keep in inside and let you peek at one class at a time. Balls to that, simply can't see whats happening or what your looking for, not worth the time  spent doing it.

And to tell the truth, I "STILL" feel like I'm letting myself down for not going lock stock and barrel for unmanged C++. There's so much hype and big biz and competition and the flaming web  that quality seems to be of little importance now. And at the end  of the day  MS or IBM will just step in and clean up on anything worth a sod anyway ... take a look at greatplains.com or axapta .... there goes any chance of moving out of anything but small time. Any mid sized company would HAVE to get the MS gear in at that level ...and who'd blame them ?

 
Answer #4    Answered By: Vicki Fields     Answered On: Jun 17

As I said in a later one ... I like the idea  of wrapping images  into a resource dll and sitting them on the server, perhaps ; .... I want to experiment with it.

 
Answer #5    Answered By: Isra Demir     Answered On: Jun 17

You don't think MS are holding back  do you ?

Both those two you sent me were written by them, and got all the way round the block till the last hurdle, where they fell.

The one from DotDotNet takes an image  and the goes through replacing pixels with characters and making  a table, then ouputs the table as html.
Absolutley useless concept - like a bike with square wheels.

The other one may be a little better, a httphandler than handles requests.
Basically this one takes a <img src="somestring"> where "somestring" is a an url  to a page  containing code writing an altered image to Response.Output stream.

I may be able to wangle and twist this second one into doing something maybe a little more up my street, i.e. make that httphandler handle requests from server  code, i.e. if a control  wants an ImageUrl then set it to an url that will generate the image - BUT without the physicallity and the overhead of an aspx  page, I think ... maybe I can write a httphandler to handle it all internally within my dll, will have to fool the control into thinking it's an url that's all.

 
Didn't find what you were looking for? Find more on Images in designer Or get search suggestion and latest updates.




Tagged: