MTM2.com

A forum for mtm2 discussion
FAQ :: Search :: Members :: Groups :: Register
Login
It is currently Fri Nov 22, 2024 5:43 am



Post new topic Reply to topic  [ 18 posts ] 
Author Message
 Post subject: VB6 Code (Raw Files)
PostPosted: Wed Dec 17, 2003 8:13 pm 
Member
User avatar

Joined: Thu Jun 12, 2003 4:58 pm
Posts: 115
Location: USA
Hey guys, I was messing around with VB6, and I got a idea for a little tool. But I am having a heck of a time with the code. I can get .BMPs, .JPGs and others to open, but I cant figure out how to open .RAW files.

If anyone has any ideas, PLEASE let me know.

Thanks :D

_________________
TEAM XTREME
------XFA-----
Team Captain


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 4:00 pm 
Member
User avatar

Joined: Thu Apr 19, 2001 2:01 pm
Posts: 695
Location: USA and Proud of it.
gotta convert the raw+act to bmp first.

_________________
Keep on MTMing,
CH_2005
<a href="http://ch.mtm2.com/">Visit my site</a>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 4:37 pm 
Member
User avatar

Joined: Thu Jun 12, 2003 4:58 pm
Posts: 115
Location: USA
Darn, I wanted to be able to open a RAW in VB. That stinks. Oh well there goes my idea.

Thanks CH

_________________
TEAM XTREME
------XFA-----
Team Captain


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 11:04 pm 
Member
User avatar

Joined: Fri May 04, 2001 2:01 pm
Posts: 495
Location: Bathurst, NSW, Australia
If the data's in a file, you can read it. But you might be stuck writing your own custom loading code to interpret it (I'm assuming VB will let ya get down to the level of bits and bytes), and to do so you'll need to know the structure and format of the file data. You might be able to look up the format for RAW and ACT files and write your own program to read them direct, if you want to make yourself a really involved project...

_________________
10 years of MTM2 ~ 1998-2008
"Thanks for the MTMories"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 6:23 pm 
Member
User avatar

Joined: Thu Jun 12, 2003 4:58 pm
Posts: 115
Location: USA
Thanks. Ill see what I can find and comeup with. I never would of thought that all this would be so tough just to open and view a RAW file like a picture in VB

_________________
TEAM XTREME
------XFA-----
Team Captain


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 21, 2003 3:56 pm 
Member
User avatar

Joined: Thu Apr 19, 2001 2:01 pm
Posts: 695
Location: USA and Proud of it.
raw is just as many bytes as pixles
no header or anything - it's very 'raw' data
the act is similar, it has 3 bytes for each color and 256 colors
act = adobe color table
each color has a red byte a blue byte and a green byte
so the file goes: rgbrgbrgbrgbrgb etc.
each byte in the raw file points to a color in the act table.

i wrote all the code for converting raw+act>bmp and bmp>raw+act for c-pod, i'm grounded right now but i can get u the source code or that after xmas.
right now i am on break at work.

it's really rather simple.

try writing the rest of the program while u wait . lol.

ttyl

_________________
Keep on MTMing,
CH_2005
<a href="http://ch.mtm2.com/">Visit my site</a>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 21, 2003 4:20 pm 
Member
User avatar

Joined: Thu Jun 12, 2003 4:58 pm
Posts: 115
Location: USA
Thanks CH.
I have tried a couple of diff. things but couldnt get any of them to work. I just really need to see how some things are written, and get the basic idea of somethings I am having trouble with.

I will be waiting for the source code, when ever you have time. I am not in a rush. Any help you can send my way, would be great.

Thanks again CH :D

_________________
TEAM XTREME
------XFA-----
Team Captain


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 12:02 pm 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
> i'm grounded right now ...

Rumor has it that geodesic domes will do that to a person :o)

Hey man, as long as you're sharing a few lines of code, please include me on your christmas list. I'm always interested in the stuff you're doing. Thanks.

And, more importantly, try to have a nice christmas at home, eh?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 4:41 pm 
Member
User avatar

Joined: Thu Apr 19, 2001 2:01 pm
Posts: 695
Location: USA and Proud of it.
Merry xmas :)
And i made it myself :) always the best kind of gift.
p.s. my dome has xmas lights on it :)
Code:
Private Function Bmp2Raw(BmpPath$, RawPath$)
   
    BmpNum = FreeFile
    Open BmpPath$ For Binary As BmpNum
       
        '''''''''''''''''''''File header'''''''''''''''''''''''
        'this is the file type: must be BM
        bfType$ = String(2, 0)
        Get #BmpNum, , bfType$
        If bfType$ <> "BM" Then
            MsgBox "Invalid Bin Type", , "Error..."
            Exit Function
        End If
       
        'Specifys the size of the bmp file
        FourSize$ = String(4, 0)
        Get #BmpNum, , FourSize$
        bfSize = FourByteNumber(FourSize$)
       
        'these are two 2byte things that must be 0
        Get #BmpNum, , FourSize$
       
        'This tells the offset of the bitmap data : usually 1078
        Get #BmpNum, , FourSize$
        bfOffBits = FourByteNumber(FourSize$)
       
        ''''''''''''''Info'Header'''''''''''''''''''''''''''''
        'size of this second header - the info of the bmp
        Get #BmpNum, , FourSize$
        biSize = FourByteNumber(FourSize$)
       
        'Width of the image in pixles
        Get #BmpNum, , FourSize$
        biWidth = FourByteNumber(FourSize$)
        If biWidth Mod 4 <> 0 Then
            MsgBox "BMP Width not multipul of four.", , "Error"
            Exit Function
        End If
       
        'Height of the image in pixles
        Get #BmpNum, , FourSize$
        biHeight = FourByteNumber(FourSize$)
        If biHeight Mod 4 <> 0 Then
            MsgBox "BMP Height not multipul of four.", , "Error"
            Exit Function
        End If
       
        If biHeight <> biWidth Then
            MsgBox "BMP is not square.", , "Error"
            Exit Function
        End If
       
        'number of planes in the target device, must be 0
        TwoSize$ = String(2, 0)
        Get #BmpNum, , TwoSize$
        biPlanes = TwoByteNumber(TwoSize$)
        If biPlanes <> 1 Then
            MsgBox "Number of planes not one.", , "Error"
            Exit Function
        End If
       
        'Bit count per pixle 8 is 256
        Get #BmpNum, , TwoSize$
        biBitCount = TwoByteNumber(TwoSize$)
        If biBitCount <> 8 Then
            MsgBox "Bits per pixle not 8. In other words this is not a 256 color BMP.", , "Error"
            Exit Function
        End If
       
        'Compression Type
        Get #BmpNum, , FourSize$
        biCompression = FourByteNumber(FourSize$)
        If biCompression <> 0 Then
            MsgBox "A compressed BMP? Are you crazy?", , "Error"
            Exit Function
        End If
       
        'Specifys the size of the bmp data 0 is ok if no compression
        '65536 for a 256x256
        '256 for a 16x16
        Get #BmpNum, , FourSize$
        biSizeImage = FourByteNumber(FourSize$)
        If biSizeImage <> 0 And biSizeImage <> biWidth * biHeight Then
            MsgBox "Somthing is screwy here...The height*width*8/8 isnt equal to the image size!", , "Error"
            Exit Function
        End If
       
        'specifies the the horizontal pixels per meter on the designated targer device, usually set to zero.
        Get #BmpNum, , FourSize$
        biXPelsPerMeter = FourByteNumber(FourSize$)
        'specifies the the vertical pixels per meter on the designated targer device, usually set to zero.
        Get #BmpNum, , FourSize$
        biYPelsPerMeter = FourByteNumber(FourSize$)
       
        'specifies the number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member.
        Get #BmpNum, , FourSize$
        biClrUsed = FourByteNumber(FourSize$)
       
        'specifies the number of color that are 'important' for the bitmap, if set to zero, all colors are important.
        Get #BmpNum, , FourSize$
        biClrImportant = FourByteNumber(FourSize$)
       
        'Ok, here's the first fun part - write the ACT :)
        ActPath$ = Left(RawPath$, Len(RawPath$) - 3) & "ACT"
        If Dir$(ActPath$) <> "" Then Kill ActPath$
        ActNum = FreeFile
        Open ActPath$ For Binary As ActNum
            For Colour = 1 To 256
                Red$ = String(1, 0)
                Get #BmpNum, , Red$
                Green$ = String(1, 0)
                Get #BmpNum, , Green$
                Blue$ = String(1, 0)
                Get #BmpNum, , Blue$
                Reserved$ = String(1, 0)
                Get #BmpNum, , Reserved$
                Put #ActNum, , Blue$
                Put #ActNum, , Green$
                Put #ActNum, , Red$
            Next Colour
        Close ActNum
       
        'Ok, here's the second fun part - write the RAW :)
        For Rows = 1 To biHeight
            Row$ = String(biWidth, 0)
            Get #BmpNum, , Row$
            RowSum$ = Row$ & RowSum$
        Next Rows
        If Dir$(RawPath$) <> "" Then Kill RawPath$
        RawNum = FreeFile
        Open RawPath$ For Binary As RawNum
            Put #RawNum, , RowSum$
        Close ActNum
       
    Close BmpNum
   
End Function

Private Function Raw2Bmp(RawPath$, ActPath$, BmpPath$)

    DoEvents
   
    'This function will take:
    '  a raw file RawPath$ and a
    '  an adobe color table (act) file ActPath$
    '  and export a bmp to BmpPath$
   
    'A RAW file is an image file with no dimensions or color info
    ' it is assumed to be square, so we take the len of the file
    ' and squarert it to get the height and width. Each byte in a RAW
    ' is a pixle, it's color is the nth color in the ACT - n being
    ' the value of the byte. I believe that the pixles go from left
    ' to right and then top to bottom.
    'An ACT file has 255 sets of 3 bytes - 1 set for each color, RGB
    ' therefor the first set will start at 0 (1 in vb) and the last
    ' will start with 765 (766 in vb), So to figure out the number
    ' of colors do the len of the file divided by 3 and subtract 1
   
   
    '-------Loading ACT Colors:
   
    Dim ActRed(255) 'Holds 256 Red Values from the ACT (locations: 0,3,6,9...765 in act (1,4,7,10,767 in vb))
    Dim ActGreen(255) 'Holds 256 Green Values from the ACT(locations: 0,3,6,9...765 in act (1,4,7,10,767 in vb))
    Dim ActBlue(255) 'Holds 256 Blue Values (locations: 0,3,6,9...765 in act (1,4,7,10,767 in vb))
   
   
    StatusBar1.SimpleText = "Reading ACT..."
    'Opens ACT file for Binary :)
    ActFileNum = FreeFile
    Open ActPath$ For Binary As #ActFileNum
   
        'Since there are 3 bytes per color - This should usually be 256.
        NumOfColors = LOF(ActFileNum) / 3
       
        'One time through loop for each color in table.
        'Store in 0-255 instad of 1-256
        For Ind = 0 To NumOfColors - 1
            ActRed(Ind) = Asc(Input$(1, #ActFileNum))      'get red
            ActGreen(Ind) = Asc(Input$(1, #ActFileNum))    'and green
            ActBlue(Ind) = Asc(Input$(1, #ActFileNum))     'and blue
        Next Ind
    Close #ActFileNum
   
    'Uncomment this to have it print a msgbox with all the act values.
    'Message = "ACT Values: "
    'For i = 0 To NumOfColors - 1
    '    Message = Message & "Index: " & i
    '    Message = Message & Str$(ActRed(i)) & ","
    '    Message = Message & Str$(ActGreen(i)) & ","
    '    Message = Message & Str$(ActBlue(i)) & " "
    'Next i
    'MsgBox (Message)
   
       
    '-------Loading RAW Index Table
    StatusBar1.SimpleText = "Reading RAW..."
    'Dim PixelIndex(262144) 'Stores the index numbers (with values of 0-255)
                           ' (one per pixel)
                           'Make enough room for a 512x512 Raw!
                           
    NumOfPixels = FileLen(RawPath$)
   
    If Sqr(NumOfPixels) <> Int(Sqr(NumOfPixels)) Then
        MsgBox ("RAW is not square, quitting operation.")
        Raw2Bmp = 0
        Exit Function
    End If
    If NumOfPixels / 4 <> Int(NumOfPixels / 4) Then
        MsgBox ("Width of RAW not evenly divisable by four, quitting operation.")
        Exit Function
    End If
   
    RawPathNum = FreeFile
    Open RawPath$ For Binary As #RawPathNum
        NumOfPixels = LOF(RawPathNum)                   'So we can use that latter
        For i = 1 To LOF(RawPathNum) / Sqr(NumOfPixels)
            'PixelIndex(i) = Asc(Input$(1, #RawPathNum)) 'Get that pixel
            ThisData$ = Input$(Sqr(NumOfPixels), #RawPathNum) & ThisData$
        Next i
        'ThisData$ = ThisData$ & Input$(256, #RawPathNum)
    Close #RawPathNum
   
    MyHeight = Sqr(NumOfPixels)
    MyWidth = Sqr(NumOfPixels)
   
    'Prints a msgbox with the pixel indicies:
    'Message = "RAW Indicies: "
    'For i = 1620 To 1700
    '    Message = Message & Str$(PixelIndex(i)) & ","
    'Next i
    'MsgBox (Message)
   
   
    StatusBar1.SimpleText = "Writing BMP..."
    '-------Save the BMP!!!!!!!!
    'Heres where i got my BMP File Format info:
    ' http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html
   
    RowLength = MyWidth             'this is used for storing the DBI later.
    RowExtra = 0                    'keeping trck of how many 00's are added
    Do While RowLength / 4 <> Int(RowLength / 4) 'has to be multipul of 4
        RowLength = RowLength + 1                'you'll undertand later
        RowExtra = RowExtra + 1
    Loop
   
    If Dir$(BmpPath$) <> "" Then Kill BmpPath$
    BmpFileNum = FreeFile
    Open BmpPath$ For Binary As #BmpFileNum
           
            Dim FourLong As String * 4
            Dim TwoLong As String * 2
           
            'The BITMAPFILEHEADER:
            'start   size   name         stdvalue   purpose
            ' 1       2      bfType       19778      must always be set to 'BM' to declare that this is a .bmp-file.
            ' 3       4      bfSize       ??         specifies the size of the file in bytes.
            ' 7       2      bfReserved1  0          must always be set to zero.
            ' 9       2      bfReserved2  0          must always be set to zero.
            ' 11      4      bfOffBits    1078       specifies the offset from the beginning of the file to the bitmap data.
           
            Dim bfType As String * 2
            bfType$ = "BM"                          'BMP ID
            Put #BmpFileNum, , bfType$
           
            bfSize = 14                             'File Header
            bfSize = bfSize + 40                    'Info Header
            bfSize = bfSize + 4 * (NumOfColors)     'rgbQuad
            bfSize = bfSize + MyHeight * (RowLength) 'DBI
            FourLong = Make4ByteString$(bfSize)        'PUT CODE HERE TO CONVERT TO 4 BYTE STRING!!!!!!!!
            Put #BmpFileNum, , FourLong
           
            bfReserved1 = String$(2, Chr$(0))       'must always be set to zero
            TwoLong = bfReserved1
            Put #BmpFileNum, , TwoLong
            bfReserved2 = String$(2, Chr$(0))       'must always be set to zero
            TwoLong = bfReserved2
            Put #BmpFileNum, , TwoLong
           
            bfOffBits = 1078                        'specifies the offset from the beginning of the file to the bitmap data
                                                    ' 1078 works for 8bit bmp files
            bfOffBits = Make4ByteString$(bfOffBits)  'PUT CODE HERE TO CONVERT TO 4 BYTE STRING!!!!!!!!
            FourLong = bfOffBits
            Put #BmpFileNum, , FourLong
           

            'The BITMAPINFOHEADER:
            'start  size    name            stdvalue    purpose
            ' 15     4       biSize          40          specifies the size of the BITMAPINFOHEADER structure, in bytes.
            ' 19     4       biWidth         100         specifies the width of the image, in pixels.
            ' 23     4       biHeight        100         specifies the height of the image, in pixels.
            ' 27     2       biPlanes        1           specifies the number of planes of the target device, must be set to zero.
            ' 29     2       biBitCount      8           specifies the number of bits per pixel.
            ' 31     4       biCompression   0           Specifies the type of compression, usually set to zero (no compression).
            ' 35     4       biSizeImage     0           specifies the size of the image data, in bytes. If there is no compression, it is valid to set this member to zero.
            ' 39     4       biXPelsPerMeter 0           specifies the the horizontal pixels per meter on the designated targer device, usually set to zero.
            ' 43     4       biYPelsPerMeter 0           specifies the the vertical pixels per meter on the designated targer device, usually set to zero.
            ' 47     4       biClrUsed       0           specifies the number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member.
            ' 51     4       biClrImportant  0           specifies the number of color that are 'important' for the bitmap, if set to zero, all colors are important.
             
            biSize = 40                                 'specifies the size of the BITMAPINFOHEADER structure, in bytes.
            biSize = Make4ByteString$(biSize)            'PUT CODE HERE TO CONVERT TO 4 BYTE STRING!!!!!!!!
            FourLong = biSize
            Put #BmpFileNum, , FourLong
           
            biWidth = MyWidth                           'specifies the width of the image, in pixels.
            biWidth = Make4ByteString$(biWidth)          'PUT CODE HERE TO CONVERT TO 4 BYTE STRING!!!!!!!!
            FourLong = biWidth
            Put #BmpFileNum, , FourLong
            biHeight = MyHeight                         'specifies the height of the image, in pixels.
            biHeight = Make4ByteString$(biHeight)        'PUT CODE HERE TO CONVERT TO 4 BYTE STRING!!!!!!!!
            FourLong = biHeight
            Put #BmpFileNum, , FourLong
           
            biPlanes = 1                                'specifies the number of planes of the target device, must be set to zero.
            biPlanes = Make2ByteString(biPlanes)        'PUT CODE HERE TO CONVERT TO 2 BYTE STRING!!!!!!!!
            TwoLong = biPlanes
            Put #BmpFileNum, , TwoLong
           
            biBitCount = 8                              'specifies the number of bits per pixel.
            biBitCount = Make2ByteString(biBitCount)    'PUT CODE HERE TO CONVERT TO 2 BYTE STRING!!!!!!!!
            TwoLong = biBitCount
            Put #BmpFileNum, , TwoLong

            biCompression = String$(4, Chr$(0))         '<
            FourLong = biCompression
            Put #BmpFileNum, , FourLong
            biSizeImage = String$(4, Chr$(0))           '< See above for
            FourLong = biSizeImage
            Put #BmpFileNum, , FourLong
            biXPelsPerMeter = String$(4, Chr$(0))       '< why these have
            FourLong = biXPelsPerMeter
            Put #BmpFileNum, , FourLong
            biYPelsPerMeter = String$(4, Chr$(0))       '< values of 0
            FourLong = biYPelsPerMeter
            Put #BmpFileNum, , FourLong
           
           
            biClrUsed = NumOfColors                     'Number of colors
            biClrUsed = Make4ByteString$(biClrUsed)      'PUT CODE HERE TO CONVERT TO 4 BYTE STRING!!!!!!!!
            FourLong = biClrUsed
            Put #BmpFileNum, , FourLong
           
           
            biClrImportant = String$(4, Chr$(0))        '<
            FourLong = biClrImportant
            Put #BmpFileNum, , FourLong
           
           
            'The RGBQUAD array:
            'start  size    name        stdvalue    purpose
            ' 1      1       rgbBlue       -         specifies the blue part of the color.
            ' 2      1       rgbGreen      -         specifies the green part of the color.
            ' 3      1       rgbRed        -         specifies the red part of the color.
            ' 4      1       rgbReserved   -         must always be set to zero.
           
            Dim OneLong As String * 1
            For Colour = 0 To NumOfColors - 1
           
                rgbBlue = ActBlue(Colour)
                rgbBlue = Chr$(rgbBlue)
                OneLong = rgbBlue
                Put #BmpFileNum, , OneLong
               
                rgbGreen = ActGreen(Colour)
                rgbGreen = Chr$(rgbGreen)
                OneLong = rgbGreen
                Put #BmpFileNum, , OneLong
               
                rgbRed = ActRed(Colour)
                rgbRed = Chr$(rgbRed)
                OneLong = rgbRed
                Put #BmpFileNum, , OneLong
               
                rgbReserved = String$(4, Chr$(0))
                OneLong = rgbReserved
                Put #BmpFileNum, , OneLong
               
            Next Colour
           
            'Now the bitmap data! Finaly!
           
            'Some notes on the way it's stored:
           
            'In 8-bit mode every byte represents a pixel.
            ' The value points to an entry in the color table
            ' which contains 256 entries
           
            'It is important to know that the rows of a DIB are stored
            ' upside down. That means that the uppest row which appears
            ' on the screen actually is the lowest row stored in the bitmap
           
            'Another important thing is that the number of bytes in one row
            ' must always be adjusted to fit into the border of a multiple
            ' of four. You simply append zero bytes until the number of
            ' bytes in a row reaches a multiple of four, an example:
            '   6 bytes that represent a row in the bitmap: A0 37 F2 8B 31 C4
            '   must be saved as: A0 37 F2 8B 31 C4 00 00
            ' to reach the multiple of four which is the next higher after six (eight).
           
            'ThisData$ = ""
            'StatusBar1.SimpleText = "Writing Pixels..."
            'Progress.Max = NumOfPixels
            'Progress.Value = 0
            'For Row = MyHeight - 1 To 0 Step -1
            '    For Col = 0 To MyWidth - 1
            '        StatusBar1.SimpleText = "Writing Pixel:" & Str$(Progress.Value) & " of" & Str$(Progress.Max)
            '        Progress.Value = Progress.Value + 1
            '        ThisData$ = ThisData$ & Chr$(PixelIndex(Row * MyWidth + Col))
            '    Next Col
            '    For X = 1 To RowExtra
            '        ThisData$ = ThisData$ & Chr$(0)
            '    Next X
            'Next Row
            'Progress.Value = 0
           
            Put #BmpFileNum, , ThisData$

        Close #BmpFileNum
        StatusBar1.SimpleText = "Ready."
        gPicContent$ = ""
       
        Raw2Bmp = MyHeight
       
       
End Function

Private Function Make4ByteString$(MyNumber)

    Hexa = Hex$(MyNumber)
    Do While Len(Hexa) < 8
        Hexa = "0" & Hexa
    Loop
    LittleEndien = Mid$(Hexa, 7, 2) & Mid$(Hexa, 5, 2) & Mid$(Hexa, 3, 2) & Mid$(Hexa, 1, 2)
    Data$ = Chr(Val("&H" & Mid$(Hexa, 7, 2))) & Chr(Val("&H" & Mid$(Hexa, 5, 2))) & Chr(Val("&H" & Mid$(Hexa, 3, 2))) & Chr(Val("&H" & Mid$(Hexa, 1, 2)))
    Make4ByteString$ = Data$
   
End Function

Public Function FourByteNumber(InputData$)

    outputdata = 0
    For X = 1 To 4
        outputdata = outputdata + Asc(Mid$(InputData$, X, 1)) * 256 ^ (X - 1)
    Next X
   
    If outputdata > 2147483648# Then
        outputdata = -1 * (4294967296# - outputdata)
    End If
   
    FourByteNumber = outputdata

End Function

_________________
Keep on MTMing,
CH_2005
<a href="http://ch.mtm2.com/">Visit my site</a>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 10:41 pm 
Member
User avatar

Joined: Thu Jun 12, 2003 4:58 pm
Posts: 115
Location: USA
WOW, *Scratches Head*
Thanks ALOT CH, this will help me out (and teach me alot ).

Have a Merry Christmas and a safe new year.
Thanks again

_________________
TEAM XTREME
------XFA-----
Team Captain


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 2:01 pm 
Member
User avatar

Joined: Thu Apr 19, 2001 2:01 pm
Posts: 695
Location: USA and Proud of it.
any luck?

_________________
Keep on MTMing,
CH_2005
<a href="http://ch.mtm2.com/">Visit my site</a>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 4:08 pm 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
I haven't had much of a chance to look at this yet. Once I get all the other loose ends tied up I'll turn my attention here and see what I can make happen.

And, I would guess meth's studies take most of his time but I think it's a safe bet he's still scratching his head over this, lol.

I can't predict the results that will come out of this but no way it's been overlooked or forgotten, you can count on that.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 1:44 am 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
<table cellspacing="1" cellpadding="3" border="0"><tr><td class="quote">any luck?</td></tr></table>
Yes.


<table cellspacing="1" cellpadding="3" border="0"><tr><td class="quote"> MsgBox "A compressed BMP? Are you crazy?", , "Error" </td></tr></table>
LOL


>> http://mtm2.com/~mtmg/downloads/misc/so ... RawGui.exe

ROFL


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 10:03 pm 
Member
User avatar

Joined: Thu Apr 19, 2001 2:01 pm
Posts: 695
Location: USA and Proud of it.
Two years worth of loose ends?!?! Geeze!


By the way, the code is all horrible. lol.

Code:
        'Specifys the size of the bmp file
        FourSize$ = String(4, 0)
        Get #BmpNum, , FourSize$
        bfSize = FourByteNumber(FourSize$)


Ok, Remember how you're supposed to 'dim' (dimension) variables?
Well at the time I wrote C-POD I didnt really know this. VB will autodim variables for you if you decide to be as lazy as I was when I wrote C-POD. Problem is that it will dim them to a type called 'Variant'. Since I didnt know about diming variables i had this great idea of pseudodiming the variants to certain lengths by calling String(4, 0) which makes a string that is 4 characters long with all chars being null characters. That way I could read in the 4 bytes from a file using Get. Then to convert the 4 bytes into a long I call the :
FourByteNumber(InputData$)
function.

If I just dimmed them to Long (meaning 4 byte integer) then VB would have automated all that for me.

i.e.
Code:
        'Specifys the size of the bmp file
        Dim bfSize as Long
        Get #BmpNum, , bfSize


Notice I save about 5 steps.

Countless sloppy programming errors such as this are the reason that C-POD runs so horribly Slowly. lol. sry. I was like 13 or 14. Please forgive me.

_________________
Keep on MTMing,
CH_2005
<a href="http://ch.mtm2.com/">Visit my site</a>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 10:38 pm 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
What I find interesting is that you were reading the specific aspects of the file before you had a sound grasp of programming form. Yes, I noticed many problems when c-pod was being made but who are we to complain. And yes I noticed oddities in the above code... and used it anyway, making adjustments where necessary in order to make it work. If we were really on the ball, we'd streamline the whole process and make it as efficient as possible. Maybe one day, but for me, at the moment, the task is just figuring out file structures and like that. We can work on points for style once we have a better understanding. And for what it's worth, when I make something, first I get it working. If it doesn't work, then what does anything else matter? Then, and only then, I add "option explicit" and keep running it while it perspires an' sobs, and cries an' shutters, and whimpers an' pulls handfuls of hair off'n its head, and bites his lip, and sometimes falls over in a dead faint. But for now, it works, albeit slower than ideal, but it's in the right direction. Nothing to forgive, and only thanks and acknowledgement and gratitude to return.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 12:54 am 
Member
User avatar

Joined: Thu Apr 19, 2001 2:01 pm
Posts: 695
Location: USA and Proud of it.
Yea, that was probably more encouraging.

I like to put option explicit on first so that if I misspell something it will tell me. Also that makes VB more like other programming languages and is therefore probably better for somone who switches back and forth a lot.

Here's a new tip.

Check out that Class file that u linked me to earlier. You will see that you can define your own data types. You could have a data type that consists of two longs and a 32 char string for example. This is useful cause u can have different data types for different blocks in the BIN. Then you can read a whole block with one Get statement.

_________________
Keep on MTMing,
CH_2005
<a href="http://ch.mtm2.com/">Visit my site</a>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 2:53 am 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
> option explicit ... makes VB more like other programming languages

Some days I think vb is modeled after perl.


> that Class file that u linked me to earlier

Yes, I saw that, and I used custom data types for smurf. Had no choice, the arrays were breaking down and objects were more than I was ready to deal with - still are, I think.


> Then you can read a whole block with one Get statement.

In time, I will ask you about this again. Right now I have a dozen other things on the go but once I get all the other loose ends tied up I'll turn my attention back here and see what I can make happen.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 7:36 am 
Member
User avatar

Joined: Thu Jun 12, 2003 4:58 pm
Posts: 115
Location: USA
Quote:
Two years worth of loose ends?!?! Geeze!

I am learning this stuff, slowly. :)

Quote:
who are we to complain


I hope people remember that when I start messing around with VB again, lol

_________________
TEAM XTREME
------XFA-----
Team Captain


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ] 


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group