Using Save picture as JPEG command how ?

Beginner

Well-known member
Joined
Mar 12, 2008
Messages
114
Programming Experience
Beginner
Does anyone have any articles about saving picture as JPEG ?

2006148200319099889_rs.jpg


If im to do a save picture as for this forum. Is it more like photoshop ? Layers ? Is there a simple way to extract the whole form into a JPEG ?
 
Found this from a Google search. Looks like it would work. You could have found it too!

VB.NET:
Private Shared Function BitBlt( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Integer _
) As Boolean
End Function

Private Shared SRCCOPY As Integer = &HCC0020

Private Sub SaveFormToFile(ByVal sourceForm As Form, ByVal filename As String)
Dim formGraphics As Graphics = sourceForm.CreateGraphics()

Dim
bufferRect = sourceForm.ClientRectangle
Dim buffer As Image = New Bitmap(bufferRect.Width, bufferRect.Height, formGraphics)
Dim bufferGraphics As Graphics = Graphics.FromImage(buffer)

Dim formDC As IntPtr = formGraphics.GetHdc()
Dim bufferDC As IntPtr = bufferGraphics.GetHdc()

BitBlt(bufferDC, 0, 0, bufferRect.Width, bufferRect.Height, formDC, 0, 0, SRCCOPY)

bufferGraphics.ReleaseHdc(bufferDC)
formGraphics.ReleaseHdc(formDC)

bufferGraphics.Dispose()
formGraphics.Dispose()

buffer.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg)
buffer.Dispose()
End Sub
 
How about a print screen function with the size of the form
 
Thanx , the closest feature there is printform and basically it does not do the print screen its to allow the user what to print.

heres what i want to do.

i want to add a button somewhere here.

2006148200319099889_rs.jpg


When that button is clicked. The print screen function will caputure the form and i'll be getting something like:

2005462669515036518_rs.jpg
 
Thanks i wasnt paying attention to the code. May you give me the source URL of the code, please ? Thanx..
 
problem Solved heres my code




VB.NET:
    Private Sub SaveImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveImage.Click
        Dim sfd As New SaveFileDialog
        sfd.Filter = "JPG files (*.jpg)|*.jpg"
        sfd.ShowDialog()
        If sfd.FileName <> "" Then
            Dim a As Graphics = Graphics.FromImage(Me.BackgroundImage)
            a.DrawString(GearTeeths.Text, New Font(New FontFamily("Tahoma"), 8), Brushes.Black, 12, 342)
            a.DrawString(PinionTeeths.Text, New Font(New FontFamily("Tahoma"), 8), Brushes.Black, 12, 360)
            a.DrawString(DC.Text, New Font(New FontFamily("Tahoma"), 8), Brushes.Black, 12, 378)
            a.DrawString(GearAngle.Text, New Font(New FontFamily("Tahoma"), 8), Brushes.Black, 113, 342)
            a.DrawString(PinionAngle.Text, New Font(New FontFamily("Tahoma"), 8), Brushes.Black, 113, 360)
            a.DrawString(Label1.Text, New Font(New FontFamily("Tahoma"), 8), Brushes.Red, 558, 360)
            a.DrawString(Label2.Text, New Font(New FontFamily("Tahoma"), 8), Brushes.Blue, 553, 378)
            Me.BackgroundImage.Save(sfd.FileName)
            MsgBox("Image saved successfully.", MsgBoxStyle.Information)
        End If

    End Sub

End Class

if im to add another option for BMP saving files.
where would i put this ??

sfd.Filter = "Bitmap Files|*.bmp"
 
Back
Top