[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Javier

1/5/2005 10:40:00 AM

Hi!

i have a problem when i want to draw, only, a part of an image. I find a
method (DrawImage()) that it can do it, but my problem is that this method
shows only a part of the image and the rest, it draw black, then when i
execute it the result is a black square and in the middle a part of the
image.

I want to know how i can draw ONLY a part of the image without the part in
black, or if its impossible that the part black become white.

I find a example but it works with a PictureBox (only for WindowsForm) and
im working with WebForms.

I hope someone can help me, thanks a lot.

Javier

PS: excuse me for my english :s


3 Answers

Bob Powell

1/5/2005 12:05:00 PM

0

I suspect that you're drawing onto an image that you've created in memory
and then exportting that image to the response stream.

Remember that a newly created image has all it's pixel elements set to zero,
this is transparent black. It's possible that the saving of the image to the
response stream doesn't save the transparency information so you'll get a
black image.

Set the image to white before you use DrawImage such as:

g.Clear(Color.White);
g.DrawImage(...);

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Javier" <javifer2000@hotmail.com> wrote in message
news:OFSyqLx8EHA.3124@TK2MSFTNGP11.phx.gbl...
> Hi!
>
> i have a problem when i want to draw, only, a part of an image. I find a
> method (DrawImage()) that it can do it, but my problem is that this method
> shows only a part of the image and the rest, it draw black, then when i
> execute it the result is a black square and in the middle a part of the
> image.
>
> I want to know how i can draw ONLY a part of the image without the part in
> black, or if its impossible that the part black become white.
>
> I find a example but it works with a PictureBox (only for WindowsForm) and
> im working with WebForms.
>
> I hope someone can help me, thanks a lot.
>
> Javier
>
> PS: excuse me for my english :s
>
>


Robby

1/5/2005 9:24:00 PM

0


Call Graphics.Clear(Color.Transparent) on the Graphics object of the new
image before you start to draw to it.

Robby

"Javier" <javifer2000@hotmail.com> wrote in message
news:OFSyqLx8EHA.3124@TK2MSFTNGP11.phx.gbl...
> Hi!
>
> i have a problem when i want to draw, only, a part of an image. I find a
> method (DrawImage()) that it can do it, but my problem is that this method
> shows only a part of the image and the rest, it draw black, then when i
> execute it the result is a black square and in the middle a part of the
> image.
>
> I want to know how i can draw ONLY a part of the image without the part in
> black, or if its impossible that the part black become white.
>
> I find a example but it works with a PictureBox (only for WindowsForm) and
> im working with WebForms.
>
> I hope someone can help me, thanks a lot.
>
> Javier
>
> PS: excuse me for my english :s
>
>


Javier

1/7/2005 11:21:00 AM

0

Thanks a lot!

to the end the solution is g.Clear(Color.Transparent) but i think that i
cannot use it because it load all the image and it is more than 1,5 Mb and
for a WebForm its very very big, then dou you know anything that it does the
same but only load the part that the user see?

Thanks!

Javier



"Robby" <edmund@not.my.email.com> escribió en el mensaje
news:ugE4vz28EHA.3376@TK2MSFTNGP12.phx.gbl...
>
> Call Graphics.Clear(Color.Transparent) on the Graphics object of the new
> image before you start to draw to it.
>
> Robby
>
> "Javier" <javifer2000@hotmail.com> wrote in message
> news:OFSyqLx8EHA.3124@TK2MSFTNGP11.phx.gbl...
> > Hi!
> >
> > i have a problem when i want to draw, only, a part of an image. I find a
> > method (DrawImage()) that it can do it, but my problem is that this
method
> > shows only a part of the image and the rest, it draw black, then when i
> > execute it the result is a black square and in the middle a part of the
> > image.
> >
> > I want to know how i can draw ONLY a part of the image without the part
in
> > black, or if its impossible that the part black become white.
> >
> > I find a example but it works with a PictureBox (only for WindowsForm)
and
> > im working with WebForms.
> >
> > I hope someone can help me, thanks a lot.
> >
> > Javier
> >
> > PS: excuse me for my english :s
> >
> >
>
>