PDA

View Full Version : گرفتن عكس از محيط ويندوز با وبي دات نت



milad.biroonvand
پنج شنبه 15 مرداد 1388, 10:26 صبح
سلام خدمت دوستان عزيز

هر كسي از شما كه كد گرفتن عكس از دسكتاپ يا از محيط ويندوز رو بلده ، كدش رو اينجا بزاره تا بقيه هم بتونن ازش استفاده بكنن.

با تشكر ميلاد بيرون وند
azad222@gmail.com

milad.biroonvand
پنج شنبه 15 مرداد 1388, 10:35 صبح
اين كد بد نيست ، اگه كسي كد بهتري داره ، اونو بذاره



' Save the desktop image.Private Sub btnGo_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnGo.Click DesktopImage().Save(txtFile.Text, ImageFormat.Bmp) MessageBox.Show("OK")End Sub



' Return an image of the desktop.Private Function DesktopImage() As Bitmap ' Get the desktop size in pixels. Dim desktop_win As Int32 = GetDesktopWindow() Dim desktop_dc As Int32 = GetDC(desktop_win) Dim desktop_bounds As Rectangle = Screen.GetBounds(New _ Point(1, 1)) Dim desktop_wid As Int32 = desktop_bounds.Width Dim desktop_hgt As Int32 = desktop_bounds.Height ' Make a Bitmap to hold the image. Dim bm As New Bitmap(desktop_wid, desktop_hgt) Dim bm_gr As Graphics = Graphics.FromImage(bm) Dim bm_hdc As IntPtr = bm_gr.GetHdc ' Copy the desktop's image. StretchBlt( _ bm_hdc, 0, 0, desktop_wid, desktop_hgt, _ desktop_dc, 0, 0, desktop_wid, desktop_hgt, _ SRCCOPY) ' Release the bitmap's and desktop's DCs. bm_gr.ReleaseHdc(bm_hdc) ReleaseDC(desktop_win, desktop_dc) ' Return the result. Return bmEnd Function

milad.biroonvand
پنج شنبه 15 مرداد 1388, 10:49 صبح
اينم خود برنامه