On Wednesday 01 June 2005 01:35, Timothy Miller wrote:
> On 5/31/05, Patrick McNamara <[EMAIL PROTECTED]> wrote:
> > >For 16 bit, you can have 565 or 555. Expanding to 888 is just a matter
> > > of adding zeroes, or again, just wiring.
> >
> > It's actually a multiply by 8 scaling factor for 555 mode, but are
> > correct, you can simply move all the bits over in the hardware.
>
> Not entirely accurate.  If you just shift, then 'b11111 becomes
> 'b11111000, which isn't right, because you really want 'b11111111.
>
> Let's consider a simple case.  You have 15 shades of gray, and you
> want to get 255.  15 evenly divides into 255, giving you 17, so you
> can multiply your 4-bit number by 17.  That's the same as just
> concatenating.
>
> wire [3:0] old_red;
> wire [7:0] new_red = {old_red, old_red};
>
> Now, following that, you'd like to do something similar when going
> from 5 to 8.  Unfortunately, it's not so easy to multiply by
> 8.225806452.  :)  However, if you do the same concatenation, you get a
> similar result.
>
> wire [4:0] old_red;
> wire [7:0] new_red = {old_red, old_red[4:2]};

You're absolutely right. Your solution works for 6 to 8 as well, if you use

 for (i=0; i<64; i++) {
  printf("%5d %5d %5d\n", i, (int)round(i*255.0/63.0), (i<<2) | (i>>4));

in that program.

Lourens

Attachment: pgpgH15Pt43Hu.pgp
Description: PGP signature

_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)

Reply via email to