Click here to Skip to main content
15,914,111 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Numericupdown Pin
Luc Pattyn30-Aug-09 10:58
sitebuilderLuc Pattyn30-Aug-09 10:58 
GeneralRe: Numericupdown Pin
Shaahinm30-Aug-09 21:41
Shaahinm30-Aug-09 21:41 
GeneralRe: Numericupdown Pin
Luc Pattyn30-Aug-09 23:41
sitebuilderLuc Pattyn30-Aug-09 23:41 
QuestionPDF Creator Pin
Bob Beaubien29-Aug-09 17:36
Bob Beaubien29-Aug-09 17:36 
AnswerRe: PDF Creator Pin
Henry Minute30-Aug-09 1:57
Henry Minute30-Aug-09 1:57 
GeneralRe: PDF Creator Pin
εїзεїзεїз30-Aug-09 5:43
εїзεїзεїз30-Aug-09 5:43 
GeneralRe: PDF Creator Pin
Henry Minute30-Aug-09 6:54
Henry Minute30-Aug-09 6:54 
QuestionDrastical performance loss Pin
Sonhospa29-Aug-09 17:21
Sonhospa29-Aug-09 17:21 
Hello everybody,

in a partial task of my project I read from file and displayed a non-GDI picture (10-bit linear-RGB DPX file). In a former approach, this took around 580 ms for a single picture. Hoping to increase the performance, I split the reading of the file and the display of the picture into 2 separate functions - which has been resulting in an immense loss of performance (7500 ms per picture now). I can't understand why D'Oh! | :doh: and how to avoid that? Maybe someone around here could recognize my blind spot and help me out?

In the newer approach, the file reading is performed by a background worker while the first picture displays. The BGW puts header and image data (as array of UInt) into a special 'dpx' class, a particular number of which are stored in a 'frames' class. This part still seems to work fine. The dpx class reads the file like
Public Function read_Image() As Array
    fsh = New FileStream(Me.FileToRead.FullName, FileMode.Open)
    brh = New BinaryReader(fsh)

    'Set the position to the proper position of the files stream.
    fsh.Position = Me.DPXOffset

    ReDim DPXPixelArray(((Me.FileToRead.Length - fsh.Position) / 4) - 1)
    For i As UInteger = 0 To Me.DPXPixelArray.GetUpperBound(0)
        Me.DPXPixelArray(i) = SwapDWORD(brh.ReadUInt32)
    Next

    fsh.Close()
    brh = Nothing

    Return DPXPixelArray

End Function
Before, all of this was part of the displaying process: read the file, swap the bytes properly, then get RGB out of the 10-bit-data into a RGB byte array (i.e. convert) and display the bitmap. Now that the DPXPixelArray holds the raw data stored in the class in order to do what ever with it, I expected to have much lesser than 580 ms for the display process, since the class only (?) has to convert the array of UInt to a bitmap. This is done with
Public Sub DisplayImage()
    If gch.IsAllocated Then gch.Free()

        Dim arrayImage() As Byte = dpx.RGBArrayFromRawArray(dpx.DPXPixelArray)
        gch = GCHandle.Alloc(arrayImage, GCHandleType.Pinned)
        Dim pBuf As IntPtr = gch.AddrOfPinnedObject
        Dim Width As Integer = dpx.DPXWidth
        Dim Height As Integer = dpx.DPXHeight
        Dim stride As Integer = Width * 3
        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
        PictureBox1.Image = New Bitmap(Width, Height, stride, Imaging.PixelFormat.Format24bppRgb, pBuf)

End Sub

Public Function RGBArrayFromRawArray(ByVal RawArray) As Array
    Dim j As Integer
    Dim RGBArray(CInt(RawArray.Length * 3) - 1) As Byte

    For i = 0 To (RawArray.Length - 1)
        j = i * 3
        Dim buff As UInteger = RawArray(i)
        ' bit-shifting operation
        RGBArray(j) = (buff And &HFFC) >> 4                    ' Blue
        RGBArray(j + 1) = (buff And &H3FFFFC) >> 14            ' Green
        RGBArray(j + 2) = (buff And &HFFFFFFFC) >> 24          ' Red
    Next i
    Return RGBArray

End Function
Measuring the elapsed time, the RGBArrayFromRawArray function alone takes more than 7 seconds now! What's wrong here? The function seems to be almost identical to what I had before...

Any hints and advice extremely welcome!
Thank
Mick


AnswerResolved: Drastical performance loss Pin
Sonhospa29-Aug-09 22:01
Sonhospa29-Aug-09 22:01 
QuestionHow to use activelock on http://www.activelocksoftware.com Pin
timnboys29-Aug-09 8:19
timnboys29-Aug-09 8:19 
AnswerRe: How to use activelock on http://www.activelocksoftware.com Pin
Henry Minute29-Aug-09 8:30
Henry Minute29-Aug-09 8:30 
GeneralRe: How to use activelock on http://www.activelocksoftware.com Pin
Luc Pattyn29-Aug-09 8:36
sitebuilderLuc Pattyn29-Aug-09 8:36 
GeneralRe: How to use activelock on http://www.activelocksoftware.com Pin
Henry Minute29-Aug-09 9:31
Henry Minute29-Aug-09 9:31 
GeneralRe: How to use activelock on http://www.activelocksoftware.com Pin
Dave Kreskowiak29-Aug-09 11:48
mveDave Kreskowiak29-Aug-09 11:48 
GeneralRe: How to use activelock on http://www.activelocksoftware.com Pin
Henry Minute29-Aug-09 12:18
Henry Minute29-Aug-09 12:18 
QuestionHow to generate MustOverride Property using CodeDOM? Pin
gutek629-Aug-09 4:34
gutek629-Aug-09 4:34 
QuestionHow to connect to XP machine using vb.net Pin
Paramhans Dubey29-Aug-09 1:22
professionalParamhans Dubey29-Aug-09 1:22 
AnswerRe: How to connect to XP machine using vb.net Pin
Dave Kreskowiak29-Aug-09 4:45
mveDave Kreskowiak29-Aug-09 4:45 
GeneralRe: How to connect to XP machine using vb.net Pin
Paramhans Dubey30-Aug-09 19:34
professionalParamhans Dubey30-Aug-09 19:34 
GeneralRe: How to connect to XP machine using vb.net Pin
Dave Kreskowiak31-Aug-09 0:58
mveDave Kreskowiak31-Aug-09 0:58 
GeneralRe: How to connect to XP machine using vb.net Pin
LloydA11131-Aug-09 15:34
LloydA11131-Aug-09 15:34 
QuestionHow we Drawing a Chart in Form Pin
faravani29-Aug-09 1:16
faravani29-Aug-09 1:16 
AnswerRe: How we Drawing a Chart in Form Pin
Luc Pattyn29-Aug-09 1:21
sitebuilderLuc Pattyn29-Aug-09 1:21 
QuestionMissingMethodException mobile aplication Pin
Anubhava Dimri29-Aug-09 1:10
Anubhava Dimri29-Aug-09 1:10 
QuestionHow to get XPath to XML node from treeview node? Pin
korell28-Aug-09 8:19
korell28-Aug-09 8:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.