JPG generated with GDI+ problem

G

Guest

hi,
i ve generated a jpeg using the GDI+ library. A part of the code i pasted
below. But surprisingly i am able to see the picture in the windows picture
viewer but i am not able to open it in photoshop. Photoshop gives an error
saying that unexpected end of file was encountered. Did any one of you face
such a problem. Can anyone help with a suitable solution..
below is some part of the code
...........
bmpTemp = New Bitmap(CType(txtWidth.Text, Integer), CType(txtHeight.Text,
Integer))
Dim g As Graphics = Graphics.FromImage(bmpTemp)
g.FillRectangle(oTBrush, 0, 0, bmpTemp.Width, bmpTemp.Height)
g.DrawString(strText, oFontFamily, oForeColor, oXPos, oYPos)
bmpTemp.Save(Request.PhysicalApplicationPath + "temp\temp.jpg", codec,
encoderParametersInstance)
....................
where the codec is "Image/jpeg" and encoderparameterinstance is 100 for
quality and 32 for colordepth..
tia
s
 
A

aatcbbtccctc

I imagine you need to show everyone how you are setting up the encoder
parameters.

I use the GDI+ "flat API" from Visual Basic for Applications (VBA), &
I've found that I get zero-length files if I do not provide a Quality
value - even a value of zero will do! So maybe you are not providing
that value?

HTH,
TC
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top