jim@athsys.uucp (Jim Becker) (02/16/89)
I need to convert the data bytes stored in a standard Sun Pixrect format to a XImage/Pixmap format on the fly. I use pr_load() to get the bytes into memory, but their format is somewhat different from that that X expects. Does anyone out there know what the magic transformation is, or have a chunk of code that does this? This is for a context sensitive help system that includes text and graphics. I started out using XImages for the graphical storage, but the ASCII version is just too big compared to Pixrect screen snapshots. I'm now trying to load and convert the Sun Pixrect files on the fly into X entities. The current code that I have, which does something close, is: struct pixrect *newpict; XImage *ximage; int w,h; . . . <load pixrect> <alloc&init XImage> . . . w = newpict->pr_size.x; h = newpict->pr_size.y; ximage->data = newpict->pr_data; ximage->width = w; ximage->height = h; ximage->format = ZPixmap; ximage->byte_order = MSBFirst; ximage->bitmap_pad = 16; ximage->bitmap_bit_order= MSBFirst; ximage->bytes_per_line = (w + 7) / 8; Thanks! -Jim Becker ...!sun!athsys!jim
david@sun.com (Pixrects are *EVIL*) (02/17/89)
In article <242@tityus.UUCP> jim@athsys.uucp (Jim Becker) writes: > ximage->bitmap_pad = 16; > ximage->bytes_per_line = (w + 7) / 8; Here are the memory pixrect padding rules for various SunOS releases: release architecture width padding ------- ------------ ----- ------- all Sun-2 all 16 bit <= 3.5 Sun-3 all 16 bit >= 4.0 Sun-3 2 bytes 16 bit >= 4.0 Sun-3 >= 4 bytes 32 bit all Sun-4 2 bytes 16 bit all Sun-4 >= 4 bytes 32 bit You should always use mpr_mdlinebytes(pr) instead of computing bytes_per_line from pr->pr_width. For details refer to the (4.0) pixrect manual. -- David DiGiacomo, Sun Microsystems, Mt. View, CA sun!david david@sun.com