Image size decreased, Please look at this and help me !!! More options

T

Tulgaa

Before running the function WriteTitle(), Pic1.jpg size was 1200 kb.
But after WriteTitle(), the picture's size was 300 kb. I don't know
what is going on, tell me please!!!!

----------------------------- Code is here
----------------------------
dim spath as string="c:\pic1.jpg"


Private function WriteTitle() as string
Using bmp As Bitmap = Image.FromFile(sPath, True)
Dim g As Graphics = Graphics.FromImage(bmp)


' r,sf,myfont are declered in the out of function
g.DrawString("hello world", myfont, Brushes.Black, r, sf)


bmp.Save("c:\pic2.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()


End Using


return "c:\pic2.jpg"
End function

---------------------------------------------------------------------------­-


.... Tulgaa
 
G

gene kelley

Before running the function WriteTitle(), Pic1.jpg size was 1200 kb.
But after WriteTitle(), the picture's size was 300 kb. I don't know
what is going on, tell me please!!!!

----------------------------- Code is here
----------------------------
dim spath as string="c:\pic1.jpg"


Private function WriteTitle() as string
Using bmp As Bitmap = Image.FromFile(sPath, True)
Dim g As Graphics = Graphics.FromImage(bmp)


' r,sf,myfont are declered in the out of function
g.DrawString("hello world", myfont, Brushes.Black, r, sf)


bmp.Save("c:\pic2.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()


End Using


return "c:\pic2.jpg"
End function

---------------------------------------------------------------------------­-


... Tulgaa

The image, Pic1.jpg, is 1200 kb because when it was created, it was saved at some
particular JPEG quality value.

In your code line to save Pic2.jpg, you are saving as Jpeg with the default Jpeg
quality value (whatever that value is). Look in the help file under Encoder Class on
how to save a Jpeg using the Encoder.Quality field to specify a specfic save quality
value.

In anticipation of a question; No, there is no easy way to determine the original
Jpeg quality setting of Pic1.jpg.


Gene
 
C

Cor Ligthert [MVP]

Tulga,

With this you create your own new image

\\\
Using bmp As Bitmap = Image.FromFile(sPath, True)
Dim g As Graphics = Graphics.FromImage(bmp)
g.DrawString("hello world", myfont, Brushes.Black, r, sf)
///
As soon as you know how, it is easy to get the information of an image using
the drawing namespace.

http://msdn2.microsoft.com/en-us/library/system.drawing(vs.80).aspx

Cor


"Tulgaa" <[email protected]> schreef in bericht
Before running the function WriteTitle(), Pic1.jpg size was 1200 kb.
But after WriteTitle(), the picture's size was 300 kb. I don't know
what is going on, tell me please!!!!

----------------------------- Code is here
----------------------------
dim spath as string="c:\pic1.jpg"


Private function WriteTitle() as string
Using bmp As Bitmap = Image.FromFile(sPath, True)
Dim g As Graphics = Graphics.FromImage(bmp)


' r,sf,myfont are declered in the out of function
g.DrawString("hello world", myfont, Brushes.Black, r, sf)


bmp.Save("c:\pic2.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()


End Using


return "c:\pic2.jpg"
End function

---------------------------------------------------------------------------­-


.... Tulgaa
 

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