Question : Bitmap Image Too Large

I have code that add a company logo as a water mark to photos and then saves them back as a jpg.  Original images are 35kb, but the new image is 600kb.  The watermark is 3kb.  1) why is the new file so large?  2) How can I save these smaller?  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
' Copy the foreground image into a bitmap.
        Dim phototouse As String
        phototouse = "C:\inetpub\wwwroot\watermark.png"        

        Dim picForeground As System.Drawing.Bitmap = New System.Drawing.Bitmap(phototouse)
        Dim fg_wid As Integer = picForeground.Width
        Dim fg_hgt = picForeground.Height
        Dim fg_bm As New Bitmap(fg_wid, fg_hgt)
        Using gr As Graphics = Graphics.FromImage(fg_bm)
            gr.DrawImage(picForeground, 0, 0, fg_wid, fg_hgt)
        End Using

        ' Make the red pixels transparent.
        fg_bm.MakeTransparent(Color.White)

        Dim photo As String = photoname
        ' Make the result bitmap.
        Dim picBackground As System.Drawing.Bitmap = New System.Drawing.Bitmap(localfolder & photo)
        Dim bg_wid As Integer = picBackground.Width
        Dim bg_hgt = picBackground.Height
        Dim bg_bm As New Bitmap(bg_wid, bg_hgt)
        If cy = 0 And cx = 0 Then
            'Need to position photo in far left corner b/c pattern not found
            cx = 0 ' Set to zero for logo in left bottom corner, set to bg_wid - 90 for logo in bottom right corner
            cy = bg_hgt - 20
        Else
            'pattern found, adjust to cover the pattern
            cx = cx - 2
            cy = cy - 11
        End If
        Using gr As Graphics = Graphics.FromImage(bg_bm)
            gr.DrawImage(picBackground, 0, 0, bg_wid, bg_hgt)

            ' Draw the foreground image on top.
            gr.DrawImage(fg_bm, cx, cy, fg_wid, fg_hgt)
        End Using

        ' Display the result.
        Dim destfile As String = localfolder & photonewname
        bg_bm.Save(destfile)

        ' We don't need the foreground bitmap any more.
        fg_bm.Dispose()

Answer : Bitmap Image Too Large

I think you are saving a bmp file in line 40 without jpeg compression


please read this page:
http://msdn.microsoft.com/en-us/library/bb882583.aspx
Random Solutions  
 
programming4us programming4us