my simple drawing code doesn't work in asp.net

T

Tony

Hello!

Below is my my code located in the Page_Load. When I run this I will only
see this.
GIF89a,2????????????????????????????3f???3333f3?3?3?ff3fff?f?f???3?f????????3?f???????3?f??????3333f3?3?3?3333333f33?33?33?3f3f33ff3f?3f?3f?3?3?33?f3??3??3??3?3?33?f3?3??3??3?3?33?f3??3??3??ff3fff?f?f?f3f33f3ff3?f3?f3?ffff3fffff?ff?ff?f?f?3f?ff??f??f??f?f?3f?ff?f??f??f?f?3f?ff??f??f????3?f??????3?33?3f?3??3?3??f?f3?ff?f??f?f?????3??f????????????3??f???????????3??f??????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f???3?f??????????3??f????????????3??f???????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f?????3??f?????????????3??f????????????3??f?????????!?,,2??
H????*\??Ç#J?H???3j???I C?I???(S?\???0c?I???8s?????@?
J???H?*]???P?J?J???X?j????`ÊK???h?]???p??K???x??????? L???È+^???i#K?L????3k?????C?M????S?^?Zo@;


Can somebody explain what I have to do to get my yellow recatngle in the
browser ?

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bitmap image = new Bitmap(300, 50);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.Yellow, 0, 0, 300, 50);
image.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Gif);

}
}

//Tony
 
T

Tony

When I run the code it looks like this

GIF89a,2����������������������������3f���3333f3�3�3�ff3fff�f�f���3�f��������3�f̙������3�f������3333f3�3�3�3333333f33�33�33�3f3f33ff3f�3f�3f�3�3�33�f3��3��3��3�3�33�f3̙3��3��3�3�33�f3��3��3��ff3fff�f�f�f3f33f3ff3�f3�f3�ffff3fffff�ff�ff�f�f�3f�ff��f��f��f�f�3f�ff̙f��f��f�f�3f�ff��f��f����3�f���̙��3�33�3f�3��3̙3��f�f3�ff�f��f̙f�����3��f�����̙������3��f�̙��̙������3��f�����̙����3�f�������3�33�3f�3��3��3��f�f3�ff�f��f��f�̙̙3̙f̙�̙�̙�����3��f�̙����������3��f�����������3�f�������3�33�3f�3��3��3��f�f3�ff�f��f��f�����3��f�������������3��f�̙����������3��f���������!�,,2��
H����*\Ȱ�Ç#J�H��ŋ3jï¿½È±ï¿½Ç C�I��ɓ(S�\ɲ�˗0cÊœI��͛8s��ɳ�ϟ@�
J��ѣH�*]ʴ�ӧP�J�J��իX�j�ʵ�ׯ`ÊK��ٳhÓª]˶�۷p�ÊK��ݻx���˷�߿� L���È+^̸��Ç#K�L���˘3k�̹��ϠC�M���ӨS�^�Zo@;

and not this
2????????????????????????????3f???3333f3?3?3?ff3fff?f?f???3?f????????3?f???????3?f??????3333f3?3?3?3333333f33?33?33?3f3f33ff3f?3f?3f?3?3?33?f3??3??3??3?3?33?f3?3??3??3?3?33?f3??3??3??ff3fff?f?f?f3f33f3ff3?f3?f3?ffff3fffff?ff?ff?f?f?3f?ff??f??f??f?f?3f?ff?f??f??f?f?3f?ff??f??f????3?f??????3?33?3f?3??3?3??f?f3?ff?f??f?f?????3??f????????????3??f???????????3??f??????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f???3?f??????????3??f????????????3??f???????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f?????3??f?????????????3??f????????????3??f?????????!?,,2??
H????*\??Ç#J?H???3j???I C?I???(S?\???0c?I???8s?????@?
J???H?*]???P?J?J???X?j????`ÊK???h?]???p??K???x???????
L???È+^???i#K?L????3k?????C?M????S?^?Zo@;


Tony said:
Hello!

Below is my my code located in the Page_Load. When I run this I will only
see this.
GIF89a,2????????????????????????????3f???3333f3?3?3?ff3fff?f?f???3?f????????3?f???????3?f??????3333f3?3?3?3333333f33?33?33?3f3f33ff3f?3f?3f?3?3?33?f3??3??3??3?3?33?f3?3??3??3?3?33?f3??3??3??ff3fff?f?f?f3f33f3ff3?f3?f3?ffff3fffff?ff?ff?f?f?3f?ff??f??f??f?f?3f?ff?f??f??f?f?3f?ff??f??f????3?f??????3?33?3f?3??3?3??f?f3?ff?f??f?f?????3??f????????????3??f???????????3??f??????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f???3?f??????????3??f????????????3??f???????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f?????3??f?????????????3??f????????????3??f?????????!?,,2??
H????*\??Ç#J?H???3j???I C?I???(S?\???0c?I???8s?????@?
J???H?*]???P?J?J???X?j????`ÊK???h?]???p??K???x???????
L???È+^???i#K?L????3k?????C?M????S?^?Zo@;


Can somebody explain what I have to do to get my yellow recatngle in the
browser ?

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bitmap image = new Bitmap(300, 50);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.Yellow, 0, 0, 300, 50);
image.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Gif);

}
}

//Tony
 
T

Tony

It work now.
For some reson it didn't work in chome but worked in IE

//Tony

Tony said:
When I run the code it looks like this

GIF89a,2����������������������������3f���3333f3�3�3�ff3fff�f�f���3�f��������3�f̙������3�f������3333f3�3�3�3333333f33�33�33�3f3f33ff3f�3f�3f�3�3�33�f3��3��3��3�3�33�f3̙3��3��3�3�33�f3��3��3��ff3fff�f�f�f3f33f3ff3�f3�f3�ffff3fffff�ff�ff�f�f�3f�ff��f��f��f�f�3f�ff̙f��f��f�f�3f�ff��f��f����3�f���̙��3�33�3f�3��3̙3��f�f3�ff�f��f̙f�����3��f�����̙������3��f�̙��̙������3��f�����̙����3�f�������3�33�3f�3��3��3��f�f3�ff�f��f��f�̙̙3̙f̙�̙�̙�����3��f�̙����������3��f�����������3�f�������3�33�3f�3��3��3��f�f3�ff�f��f��f�����3��f�������������3��f�̙����������3��f���������!�,,2��
H����*\Ȱ�Ç#J�H��ŋ3jï¿½È±ï¿½Ç C�I��ɓ(S�\ɲ�˗0cÊœI��͛8s��ɳ�ϟ@�
J��ѣH�*]ʴ�ӧP�J�J��իX�j�ʵ�ׯ`ÊK��ٳhÓª]˶�۷p�ÊK��ݻx���˷�߿�
L���È+^̸��Ç#K�L���˘3k�̹��ϠC�M���ӨS�^�Zo@;

and not this
2????????????????????????????3f???3333f3?3?3?ff3fff?f?f???3?f????????3?f???????3?f??????3333f3?3?3?3333333f33?33?33?3f3f33ff3f?3f?3f?3?3?33?f3??3??3??3?3?33?f3?3??3??3?3?33?f3??3??3??ff3fff?f?f?f3f33f3ff3?f3?f3?ffff3fffff?ff?ff?f?f?3f?ff??f??f??f?f?3f?ff?f??f??f?f?3f?ff??f??f????3?f??????3?33?3f?3??3?3??f?f3?ff?f??f?f?????3??f????????????3??f???????????3??f??????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f???3?f??????????3??f????????????3??f???????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f?????3??f?????????????3??f????????????3??f?????????!?,,2??
H????*\??Ç#J?H???3j???I C?I???(S?\???0c?I???8s?????@?
J???H?*]???P?J?J???X?j????`ÊK???h?]???p??K???x???????
L???È+^???i#K?L????3k?????C?M????S?^?Zo@;


Tony said:
Hello!

Below is my my code located in the Page_Load. When I run this I will only
see this.
GIF89a,2????????????????????????????3f???3333f3?3?3?ff3fff?f?f???3?f????????3?f???????3?f??????3333f3?3?3?3333333f33?33?33?3f3f33ff3f?3f?3f?3?3?33?f3??3??3??3?3?33?f3?3??3??3?3?33?f3??3??3??ff3fff?f?f?f3f33f3ff3?f3?f3?ffff3fffff?ff?ff?f?f?3f?ff??f??f??f?f?3f?ff?f??f??f?f?3f?ff??f??f????3?f??????3?33?3f?3??3?3??f?f3?ff?f??f?f?????3??f????????????3??f???????????3??f??????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f???3?f??????????3??f????????????3??f???????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f?????3??f?????????????3??f????????????3??f?????????!?,,2??
H????*\??Ç#J?H???3j???I C?I???(S?\???0c?I???8s?????@?
J???H?*]???P?J?J???X?j????`ÊK???h?]???p??K???x???????
L???È+^???i#K?L????3k?????C?M????S?^?Zo@;


Can somebody explain what I have to do to get my yellow recatngle in the
browser ?

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bitmap image = new Bitmap(300, 50);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.Yellow, 0, 0, 300, 50);
image.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Gif);

}
}

//Tony
 
A

Arne Vajhøj

Below is my my code located in the Page_Load. When I run this I will
only see this.
GIF89a,2????????????????????????????3f???3333f3?3?3?ff3fff?f?f???3?f????????3?f???????3?f??????3333f3?3?3?3333333f33?33?33?3f3f33ff3f?3f?3f?3?3?33?f3??3??3??3?3?33?f3?3??3??3?3?33?f3??3??3??ff3fff?f?f?f3f33f3ff3?f3?f3?ffff3fffff?ff?ff?f?f?3f?ff??f??f??f?f?3f?ff?f??f??f?f?3f?ff??f??f????3?f??????3?33?3f?3??3?3??f?f3?ff?f??f?f?????3??f????????????3??f???????????3??f??????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f???3?f??????????3??f????????????3??f???????????3?f???????3?33?3f?3??3??3??f?f3?ff?f??f??f?????3??f?????????????3??f????????????3??f?????????!?,,2??
H????*\??Ç#J?H???3j???I
C?I???(S?\???0c?I???8s?????@?
J???H?*]???P?J?J???X?j????`ÊK???h?]???p??K???x??????? L???È+^???i#K?L????3k?????C?M????S?^?Zo@;

Can somebody explain what I have to do to get my yellow recatngle in the
browser ?

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bitmap image = new Bitmap(300, 50);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.Yellow, 0, 0, 300, 50);
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);

}
}

You should:
* set Response.ContentType
* by absolutely sure that nothing is outputted before the GIF

The second is actually easier/better done via a.ashx than
a .aspx !

Arne
 
A

Arne Vajhøj

It work now.
For some reson it didn't work in chome but worked in IE

There are still a few things you need to fix in the
code - see my earlier post!

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top