IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Forms Discussion :

[VB.NET] Redimensionner Bitmap d'une capture d'écran


Sujet :

Windows Forms

  1. #1
    Membre éprouvé
    Avatar de HULK
    Inscrit en
    Juillet 2003
    Messages
    1 276
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Juillet 2003
    Messages : 1 276
    Points : 1 281
    Points
    1 281
    Par défaut [VB.NET] Redimensionner Bitmap d'une capture d'écran
    Bonjour,

    J'ai un morceau de code (dont je ne comprends pas tout) qui me fait une capture d'écran et qui me l'affiche dans un picturebox, mais je voudrais redimensionner mon bitmap car il fait la taille de mon ecran, donc quand je le met dans mon picturebox on ne voit pas tout, voici le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As String) As Integer
        Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer
        Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer
        Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
        Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer
        Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As Integer, ByVal op As Integer) As Integer
        Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer
        Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer
        Const SRCCOPY As Integer = &HCC0020
        Private oBackground As Bitmap
        Private FW, FH As Integer
     
     Protected Sub CaptureScreen()
            Dim hSDC, hMDC As Integer
            Dim hBMP, hBMPOld As Integer
            Dim r As Integer
     
            hSDC = CreateDC("DISPLAY", "", "", "")
            hMDC = CreateCompatibleDC(hSDC)
     
            FW = GetDeviceCaps(hSDC, 8)
            FH = GetDeviceCaps(hSDC, 10)
            hBMP = CreateCompatibleBitmap(hSDC, FW, FH)
     
            hBMPOld = SelectObject(hMDC, hBMP)
            r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)
            hBMP = SelectObject(hMDC, hBMPOld)
     
            r = DeleteDC(hSDC)
            r = DeleteDC(hMDC)
     
            oBackground = Image.FromHbitmap(New IntPtr(hBMP))
            DeleteObject(hBMP)
        End Sub
    j'ai essayé :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    oBackground.size = New System.Drawing.Size(584, 416)
    mais pas moyen ca me dit tjr que c'est une propriétée readonly

    Merci

  2. #2
    Membre expérimenté
    Avatar de freddyboy
    Homme Profil pro
    Architecte technique
    Inscrit en
    Novembre 2003
    Messages
    810
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2003
    Messages : 810
    Points : 1 696
    Points
    1 696
    Par défaut
    dans ton cas je pense que c'est la property sizemode qu'il faut que tu passe en stretch image.

    picture.sizemode = PictureBoxSizeMode.StretchImage ;

    @+

  3. #3
    Membre éprouvé
    Avatar de HULK
    Inscrit en
    Juillet 2003
    Messages
    1 276
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Juillet 2003
    Messages : 1 276
    Points : 1 281
    Points
    1 281
    Par défaut
    alalala magnifique, c'est vraiment quand c'est le plus simple que l'on cherche, merci A+

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Création et redimensionnement d'une capture d'écran sous vb
    Par HasnaHamidallah dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 18/04/2014, 11h05
  2. Réponses: 4
    Dernier message: 08/11/2011, 21h22
  3. Réaliser une capture d'écran
    Par izeba dans le forum Imagerie
    Réponses: 9
    Dernier message: 25/05/2007, 16h02
  4. [FAQ] [OpenGL] "Comment faire une capture d'écran ?"
    Par damienlann dans le forum Contribuez
    Réponses: 1
    Dernier message: 07/06/2006, 17h22
  5. Réponses: 10
    Dernier message: 10/10/2003, 14h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo