\r\n\r\n
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > File I/O and Registry > Put bitmap Bits Array into a Random Access file


\r\n \r\n
 
 
Thread Tools Display Modes

\r\n\r\n\r\n
I seem to be stuck on this one:
\r\n
\r\nI have an array of bitmap bits, and i need to stick them into a random access file. The problem was, it took waaaay too much space.
\r\n
\r\nAfter quite a bit of tinkering, i managed to just have each byte in the bitmap bits array added to an array of strings (each string holds 32 bytes of characters). That way, i could technically just add each string as a Random File entry.
\r\n
\r\nThis is where the real problem lies.
\r\n
\r\nIt still takes waaaay too much space, and it takes forever to save the bitmap bits to the custom file (bitmap and text into one file) if its even bigger than 32 by 32 pixels!
\r\n
\r\n
\r\nDoes anyone know of a better way? (thanks in advance)
\r\n
\r\n
\r\n
Code:
\r\n
\'Here is approximatly what it looks like, assuming TotalBytes was already dim\'ed and already has a value, and the Byte array is called \'bBYTE\'\r\n \r\n Dim I as long\r\n Dim J as long\r\n\r\n Dim MaxBytes as long\r\n Dim TotalStrings as long\r\n\r\n\r\n Dim sSTRING() as String\r\n \r\n MaxBytes = 32\r\n\r\n TotalStrings = TotalBytes / MaxBytes\r\n \r\n redim sSTRING(0 to TotalStrings)\r\n \r\n \r\n \r\n For I = 1 to TotalBytes\r\n \'Fill in Strings with Character representations of each byte\r\n sString(J) = sString(J) & chr$(bBYTE(I))\r\n \r\n \'If this string is full, use the next String\r\n if len(sString(J)) > MaxBytes then\r\n J = J + 1\r\n end if\r\n next I\r\n\r\n\r\n Open TheFile for Random as #1\r\n\r\n For I = 0 to TotalStrings\r\n \'Put each string into the file as a record\r\n Put #1, sSTRING(J)\r\n \r\n next I\r\n\r\n Close #1
\r\n
\r\n \r\n\r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n
\r\n __________________
\r\n
\r\nMy Software. (www.RedPierSystems.net)
\r\nMy Pride and Joy. (www.RedPierSystems.net)
\r\n(PHP, .net, and Java)
\r\n
\r\n
\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[443981] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 07-24-2003, 06:44 PM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
passel\'s Avatar\r\n\r\n
\r\n \r\n passel\r\n passel is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 07-24-2003, 06:33 PM
ALEX_0077's Avatar
ALEX_0077 ALEX_0077 is offline
Contributor
 
Join Date: Nov 2002
Location: American Canyon, CA
Posts: 622
Default Put bitmap Bits Array into a Random Access file


I seem to be stuck on this one:

I have an array of bitmap bits, and i need to stick them into a random access file. The problem was, it took waaaay too much space.

After quite a bit of tinkering, i managed to just have each byte in the bitmap bits array added to an array of strings (each string holds 32 bytes of characters). That way, i could technically just add each string as a Random File entry.

This is where the real problem lies.

It still takes waaaay too much space, and it takes forever to save the bitmap bits to the custom file (bitmap and text into one file) if its even bigger than 32 by 32 pixels!


Does anyone know of a better way? (thanks in advance)

Code:
'Here is approximatly what it looks like, assuming TotalBytes was already dim'ed and already has a value, and the Byte array is called 'bBYTE' Dim I as long Dim J as long Dim MaxBytes as long Dim TotalStrings as long Dim sSTRING() as String MaxBytes = 32 TotalStrings = TotalBytes / MaxBytes redim sSTRING(0 to TotalStrings) For I = 1 to TotalBytes 'Fill in Strings with Character representations of each byte sString(J) = sString(J) & chr$(bBYTE(I)) 'If this string is full, use the next String if len(sString(J)) > MaxBytes then J = J + 1 end if next I Open TheFile for Random as #1 For I = 0 to TotalStrings 'Put each string into the file as a record Put #1, sSTRING(J) next I Close #1
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Standards and Practices loquin Tutors' Corner 10 07-28-2006 12:16 PM
How to use Direct Memory Access to do Graphics BillSoo Tutors' Corner 3 07-11-2005 05:41 PM
Installation Problem - PLs help urgenlty dpdsouza Installation / Documentation 4 12-02-2004 07:09 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->