Click here to Skip to main content
15,913,722 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: calculate start and stop time Pin
Luc Pattyn6-Aug-09 4:19
sitebuilderLuc Pattyn6-Aug-09 4:19 
QuestionHow would I deal with 10-bit-integer? Pin
Sonhospa5-Aug-09 22:37
Sonhospa5-Aug-09 22:37 
AnswerRe: How would I deal with 10-bit-integer? Pin
Moreno Airoldi5-Aug-09 23:41
Moreno Airoldi5-Aug-09 23:41 
NewsRe: How would I deal with 10-bit-integer? Pin
Sonhospa6-Aug-09 1:14
Sonhospa6-Aug-09 1:14 
GeneralRe: How would I deal with 10-bit-integer? [modified] Pin
Moreno Airoldi6-Aug-09 1:47
Moreno Airoldi6-Aug-09 1:47 
GeneralRe: How would I deal with 10-bit-integer? Pin
Sonhospa6-Aug-09 9:39
Sonhospa6-Aug-09 9:39 
GeneralRe: How would I deal with 10-bit-integer? Pin
Moreno Airoldi6-Aug-09 23:34
Moreno Airoldi6-Aug-09 23:34 
GeneralRe: How would I deal with 10-bit-integer? [modified] Pin
Moreno Airoldi7-Aug-09 0:06
Moreno Airoldi7-Aug-09 0:06 
GeneralRe: How would I deal with 10-bit-integer? Pin
Sonhospa7-Aug-09 7:39
Sonhospa7-Aug-09 7:39 
GeneralRe: How would I deal with 10-bit-integer? Pin
Moreno Airoldi7-Aug-09 15:08
Moreno Airoldi7-Aug-09 15:08 
AnswerRe: How would I deal with 10-bit-integer? Pin
DidiKunz12-Aug-09 3:40
DidiKunz12-Aug-09 3:40 
GeneralRe: How would I deal with 10-bit-integer? Pin
Sonhospa13-Aug-09 10:01
Sonhospa13-Aug-09 10:01 
GeneralRe: How would I deal with 10-bit-integer? Pin
DidiKunz13-Aug-09 20:15
DidiKunz13-Aug-09 20:15 
GeneralRe: How would I deal with 10-bit-integer? Pin
Sonhospa13-Aug-09 21:47
Sonhospa13-Aug-09 21:47 
GeneralRe: How would I deal with 10-bit-integer? Pin
DidiKunz13-Aug-09 23:38
DidiKunz13-Aug-09 23:38 
GeneralRe: How would I deal with 10-bit-integer? Pin
Sonhospa14-Aug-09 9:44
Sonhospa14-Aug-09 9:44 
NewsRe: How would I deal with 10-bit-integer? [modified] Pin
Sonhospa15-Aug-09 2:08
Sonhospa15-Aug-09 2:08 
GeneralRe: How would I deal with 10-bit-integer? Pin
DidiKunz16-Aug-09 0:59
DidiKunz16-Aug-09 0:59 
GeneralRe: How would I deal with 10-bit-integer? [modified] Pin
Sonhospa16-Aug-09 2:10
Sonhospa16-Aug-09 2:10 
AnswerResolved: How would I deal with 10-bit-integer? Pin
Sonhospa16-Aug-09 6:53
Sonhospa16-Aug-09 6:53 
With some strong support I figured out the necessary changes. Here they are for others who might be interested:

1. The displayImage function has to be slightly changed: The former function 'MakePixelArray' has been replaced by a function that returns a byte array, holding 3 bytes for each pixel (RGB). As a consequence, the PixelFormat has to be adapted:
Public Sub DisplayImage(ByVal PicFile As FileInfo, ByVal ImageOffset As UInteger, ByVal Width As UInteger, ByVal Height As UInteger)
        Dim arrayImage() As Byte = MakeRGBArray(PicFile, ImageOffset)                           <--- changed routine
        Dim gch As GCHandle = GCHandle.Alloc(arrayImage, GCHandleType.Pinned)
        Dim pBuf As IntPtr = gch.AddrOfPinnedObject

        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
        PictureBox1.Image = New Bitmap(Width, Height, 3 * Width, Imaging.PixelFormat.Format24bppRgb, pBuf)      <--- changed pixel format
        gch.Free()
    End If
End Sub

2. MakeRGBArray reads a UInteger for each Pixel and swaps the bytes first. With a bit-mask and a bit-shifting operation, the padding of the Uinteger (32 bits for 3 * 10 bits RGB) is eliminated, the 10-bit-values read and converted to 8-bit:
Private Function MakeRGBArray(ByVal PicFile As FileInfo, ByVal ImageOffset As UInteger) As Array
    Dim ft As FileStream = New FileStream(PicFile.FullName, FileMode.Open)
    Dim brh As BinaryReader = New BinaryReader(ft)

    ft.Position = ImageOffset          ' start with first pixel after the header

    Dim RGBArray(CInt((PicFile.Length - ft.Position) / 4 * 3) - 1) As Byte
    For i = 0 To (RGBArray.Length - 1) Step 3
        Dim buff As UInt32 = SwapDWORD(brh.ReadUInt32)
        ' bit-shifting operation
        RGBArray(i) = (buff And &HFFC) >> 4
        RGBArray(i + 1) = (buff And &H3FFFFC) >> 14
        RGBArray(i + 2) = (buff And &HFFFFFFFC) >> 24
    Next i

    ft.Close()
    brh = Nothing
    ft = Nothing

    Return RGBArray
End Function

Maybe it helps someone else. Special thanks to Moreno for the basic idea and perfect offline support! Thumbs Up | :thumbsup:
QuestionClearing Datagridview when combobox item is changed [modified] Pin
Dambod5-Aug-09 22:31
Dambod5-Aug-09 22:31 
AnswerRe: Clearing Datagridview when combobox item is changed Pin
dan!sh 5-Aug-09 22:53
professional dan!sh 5-Aug-09 22:53 
GeneralRe: Clearing Datagridview when combobox item is changed Pin
Dambod6-Aug-09 3:59
Dambod6-Aug-09 3:59 
GeneralRe: Clearing Datagridview when combobox item is changed Pin
dan!sh 6-Aug-09 8:55
professional dan!sh 6-Aug-09 8:55 
GeneralRe: Clearing Datagridview when combobox item is changed Pin
Dambod7-Aug-09 20:30
Dambod7-Aug-09 20:30 

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.