Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - 4bpp routine | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
elixirnova Red Paratroopa Level: 22 Posts: 94/177 EXP: 56507 For next: 1843 Since: 04-05-04 From: Midgar Since last post: 1 day Last activity: 1 day |
| ||
once again ill post this since nobody helped the other time. I progressed a bit......................But i figured out how to take the bytes from my palette value and somehow i have to store the first byte as 49 but stored in my 2 vars is temp1 = 4 temp2 = 9 i used the following code to do this a b c d w x y z are vars holding pixel colors 0 - 7 respectively temp1 = ((a And &H8) Or ((b And &H8) / 2) Or ((c And &H8) / 4) Or ((d And &H8) / 8)) * &H10 temp2 = (w And &H8) Or ((x And &H8) / 2) Or ((y And &H8) / 4) Or ((z And &H8) / 8) So mainly my question is how do i take two numbers 0-F and make them one btw: 49 in binary = 0011 0001 ---4 in binary = 0100-----9 in binary = 1001 |
|||
interdpth Rex Level: 36 Posts: 342/527 EXP: 294398 For next: 13712 Since: 03-20-04 Since last post: 10 days Last activity: 31 days |
| ||
MyVar = Temp1 & Temp2 ? | |||
dan Snap Dragon Level: 43 Posts: 205/782 EXP: 534516 For next: 30530 Since: 03-15-04 Since last post: 20 hours Last activity: 14 hours |
| ||
That may not work in VB .NET, as I think it can be a git when it comes to automatically converting variables to different types. (well, from the VB perspective, it can be a git) I think the Integer object has a method called ToString, so maybe something like: MyVar = CType("&H" & temp1.ToString("x") & temp2.ToString("x"), Integer) That might work. I really don't know though, as it was completely off the top of my head with a bit of googling for the type conversion function. |
|||
sloat Level: 16 Posts: 5/85 EXP: 18044 For next: 2212 Since: 05-21-04 From: South Central Delaware Since last post: 19 days Last activity: 5 hours |
| ||
ByteVal = (HighNib * 16) Or LowNib HighNib in this case would be 4 and LowNib would be 9. &H4 * &H10 = &H40 &H40 Or &H9 = &H49 Unless I misunderstood what you were asking. |
|||
dan Snap Dragon Level: 43 Posts: 206/782 EXP: 534516 For next: 30530 Since: 03-15-04 Since last post: 20 hours Last activity: 14 hours |
| ||
Hah, I completely forgot about that when I made that post. | |||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 1844/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Originally posted by interdpth You have to use 'And', not &. In VB6, to combine a pair of 4-bit values into one 8-bit value, the simplest way is this: Result = (HighValue * 16) + LowValue However, if you haven't done any error-checking to make sure both values are <16, you'll want to use this: Result = ((HighValue And 15) * 16) + (LowValue And 15) Also when using operators like And and Or in If statments, brackets can change the whole expression. For example (a problem I actually had a while ago): If (Value And (2 ^ Bit)) = 0 Then This means 'if Value && (2 to the power of Bit) equals zero'. However, if we remove the brackets: If Value And (2 ^ Bit) = 0 Then It now means 'if Value doesn't equal zero, and (2 to the power of Bit) equals zero'. Any time you just do 'If Variable', VB assumes you mean 'If Variable <> 0' or 'If Variable = True'. (True = anything except 0 or the word 'false', so they're really the same statement.) |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - 4bpp routine | | | |