Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21740

Visual Studio crashing when writing to SD Card.

$
0
0
CAUTION: DO NOT RUN THIS CODE WITHOUT LOOKING AT IT FIRST AND UNDERSTANDING IT. IT WRITES TO YOUR G: DRIVE IN A RAW FORMAT WHEN THE COMMAND BUTTON IS CLICKED.


Hello,

I'm trying to write raw rgb565 data to an sd card in raw format but I keep crashing visual studio at odd times. The full project is zipped and attached. Im basically getting the rgb color from each pixel in a picturebox and converting to the format that I need and appending each to a string called compiled. When the string gets so long, this already slow process slows down so I split the whole thing into three strings called compiled, compiled2 and compiled3. This is all written to the SD car in one shot. Now, if I start at sector zero on the SD card, I can only write compiled and compiled2 consistantly. If I try to add compiled3 the compiler crashes. I was able to move the start sector to 2000 and write the entire string without crashing, but now it crashes too. Any idea what I'm doing wrong here? There is probably a better way to do this and probably using .Net but I have limited knowledge and have to go by what I know and the available examples on the web.

Thanks for your help.

Jason


Code:

Private Sub Command1_Click()

  List1.Visible = False
  List1.Clear

  compiled = ""
  compiled2 = ""
  compiled3 = ""

  For inc2 = 0 To 479
  For inc = 0 To 639

    PixelColor = pbPicture.Point(inc, inc2)
    ColorRed = ExtractRed(PixelColor)
    ColorGreen = ExtractGreen(PixelColor)
    ColorBlue = ExtractBlue(PixelColor)
 
    ColorRedCalc = CDec(RShiftLong(ColorRed, 3))
    ColorGreenCalc = CDec(RShiftLong(ColorGreen, 2))
    ColorBlueCalc = CDec(RShiftLong(ColorBlue, 3))
   
    ColorRedCalc = CDec(LShiftLong(ColorRedCalc, 11))
    ColorGreenCalc = CDec(LShiftLong(ColorGreenCalc, 5))
    ColorBlueCalc = ColorBlueCalc
   
    List1.AddItem (inc2 & " " & inc & " " & Hex4(ColorRedCalc + ColorGreenCalc + ColorBlueCalc))
   
    If inc2 < 150 Then compiled = compiled & hex2ascii(Hex4(ColorRedCalc + ColorGreenCalc + ColorBlueCalc))
    If inc2 > 149 And inc2 < 300 Then compiled2 = compiled2 & hex2ascii(Hex4(ColorRedCalc + ColorGreenCalc + ColorBlueCalc))
    If inc2 > 299 Then compiled3 = compiled3 & hex2ascii(Hex4(ColorRedCalc + ColorGreenCalc + ColorBlueCalc))
   
  Next inc
    DoEvents
    Label1.Caption = inc2

  Next inc2
   
    DirectWriteDriveNT "\\?\G:", 2000, 0, hex2ascii("028001E01000") & compiled & compiled2 & compiled3

    List1.Visible = True
   
End Sub

Attached Files

Viewing all articles
Browse latest Browse all 21740

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>