Pergunta

Well, I'm resizing an image in VB.NET. I have predefined algorithm that converts the image into particular size.

I just found a bug in the algorithm which causes white linings on right side of the image. After debugging the code i found that,

Dim grReturn As Drawing.Graphics = Drawing.Graphics.FromImage(bmpReturn)    
grReturn.Clear(Color.White)

causes the issue. I tried googling the issue and found just a single MSDN link which says it clears the entire drawing surface and fills it with the specified background color.

And i am not able to understand what it says!

I am able to remove white linings from my output image by commenting this Clear function. As i don't know what this function actually does, i can not remove it.

So if anyone could help me understanding the method? Will it cause any other issue if i remove this method?

Thanks!

Foi útil?

Solução

Clear method simply draws the background of the graphics to the provided color code.

As per Varocarbas comment above question,

"The explanation you are posting sounds pretty descriptive: it sets the background of the graphic (future image) to the given color. From what you are saying, your problem is not provoked because this code "draws lines", but because it makes the whole background white and the size of bmpReturn does not occupy all this background (and thus the white lines you see are not more than parts of the background). If you don't want this effect, just don't use this line of code; and, in general, you shouldn't use code whose exact functionality is not clear to you"

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top