Oppure

Loading
05/07/12 20:27
evil ways
salve a tutti,
ho creato un applicazione che scatta degli snapshot su un file in riproduzione all'interno del programma usando la libreria DirectShow. Ecco il codice:
        Dim Buff As Long
        Dim zero As IntPtr = IntPtr.Zero
        Dim Mstep As Integer
        Dim bit1 As Bitmap
        basicVideo.GetCurrentImage(Buff, zero)
        zero = Marshal.AllocCoTaskMem(Buff)
        basicVideo.GetCurrentImage(Buff, zero)
        Dim gg As New BitmapInfoHeader
        Marshal.PtrToStructure(zero, gg)
        Mstep = gg.ImageSize / gg.Height
        bit1 = New Bitmap(gg.Width, gg.Height, Mstep, Imaging.PixelFormat.Format32bppRgb, zero)
        bit1.RotateFlip(RotateFlipType.RotateNoneFlipY)
        Dim bm_dest As New Bitmap(gg.Width, gg.Height)
        Dim gr_dest As Graphics = Graphics.FromImage(bm_dest)
        gr_dest.DrawImage(bit1, 0, 0, _
                bm_dest.Width + 1, _
                bm_dest.Height + 1)
        bm_dest.Save("c:.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
        PictureBox1.Image = Nothing
        PictureBox1.Image = bit1
        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize


Per darvi un'idea ecco l'immagine corrotta:
[URL=imagebam.com/image/a28bfd200212010][IMG]http://thumbnails7.imagebam.com/20022/a28bfd200212010.jpg[/IMG][/…]

Come potete notare c'è una strisciolina a sinistra che dovrebbe essere a destra...
sapete aiutarmi?
Ultima modifica effettuata da evil ways 05/07/12 20:29
aaa
06/07/12 9:49
ampeg
da una prima occhiata veloce potrebbe essere che l'argomento n.3 (MStep) del costruttore della classe bitmap che genera l'immagine "bit1" ha un valore che sballa l'offset dell'immagine

controlla che soddisfi i requisiti del costruttore

msdn.microsoft.com/it-it/library/…
aaa
12/07/12 17:47
evil ways
Grazie ampeg per la dritta ho risolto ecco il codice

Dim Buff As Long
        Dim zero As IntPtr = IntPtr.Zero
        Dim Mstep As Integer
        Dim bit1 As Bitmap
        basicVideo.GetCurrentImage(Buff, zero)
        zero = Marshal.AllocCoTaskMem(Buff)
        basicVideo.GetCurrentImage(Buff, zero)
        Dim gg As New BitmapInfoHeader
        Marshal.PtrToStructure(zero, gg)
        Mstep = gg.Width * CInt((gg.BitCount / 8))
        bit1 = New Bitmap(gg.Width, gg.Height, -Mstep, Imaging.PixelFormat.Format32bppRgb, CType((zero.ToInt32() + gg.Size + gg.ImageSize - Mstep), IntPtr))
        Dim bm_dest As New Bitmap(gg.Width, gg.Height)
        Dim gr_dest As Graphics = Graphics.FromImage(bm_dest)
        gr_dest.DrawImage(bit1, 0, 0, _
                bm_dest.Width + 1, _
                bm_dest.Height + 1)
        bm_dest.Save("c:Grazie ampeg per la dritta ho risolto ecco il codice


Dim Buff As Long
        Dim zero As IntPtr = IntPtr.Zero
        Dim Mstep As Integer
        Dim bit1 As Bitmap
        basicVideo.GetCurrentImage(Buff, zero)
        zero = Marshal.AllocCoTaskMem(Buff)
        basicVideo.GetCurrentImage(Buff, zero)
        Dim gg As New BitmapInfoHeader
        Marshal.PtrToStructure(zero, gg)
        Mstep = gg.Width * CInt((gg.BitCount / 8))
        bit1 = New Bitmap(gg.Width, gg.Height, -Mstep, Imaging.PixelFormat.Format32bppRgb, CType((zero.ToInt32() + gg.Size + gg.ImageSize - Mstep), IntPtr))
        Dim bm_dest As New Bitmap(gg.Width, gg.Height)
        Dim gr_dest As Graphics = Graphics.FromImage(bm_dest)
        gr_dest.DrawImage(bit1, 0, 0, _
                bm_dest.Width + 1, _
                bm_dest.Height + 1)
        bm_dest.Save("c:{parsed_message}" & ics & ".jpg", System.Drawing.Imaging.ImageFormat.Bmp)
        'Threading.Thread.Sleep(1000)
" & ics & ".jpg", System.Drawing.Imaging.ImageFormat.Bmp) 'Threading.Thread.Sleep(1000)
aaa