Article View: comp.os.os2.programmer
Article #3492Re: Problem: Nasty Bitmaps
From: Larry Salomon Jr.
Date: Thu, 21 Jan 1993 15:43
Date: Thu, 21 Jan 1993 15:43
54 lines
2716 bytes
2716 bytes
In <1993Jan21.083211.3396@neptune.inf.ethz.ch> rofische@iiic.ethz.ch (Roman Fischer) writes: >we are currently writting a game running under PM. The basic idea consists of >two players simutaneiously fighting against a set of evil monsters. So we need >lots (~20) of small bitmaps that move around the screen (window). >The bitmaps were created with IconEdit and are loaded with GpiLoadBitmap. Since >we need 4 versions of every monster (looking to the left, right, up and down), >we need to "turn" the bitmaps. Because we don't want to change 4 bitmaps if >we decide to change the look of a ghost, we decided to turn them "by software" >at program-startup. So far no problem. I want a copy when you're done!!! :) > <stuff deleted> >The original size of the bitmaps is 20x20 pixels. When loading, we resize them >to 36x36 pixels. Now, when reading the data into the buffer, the x-dimension >is 40 !!!! >This means: a. GpiQueryBitmapInfo returns a cx value of 36 (as expected). > But a short look at the data received from GpiQueryBitmapBits > shows, that every scan-line consists of 40 pixels (20 bytes). > > b. You cannot use cx to calculate the offset of a pixel. > To calculate the correct offset, you need to know the number > of bytes per scan-line. > c. If you don't know the original size of the bitmap, you cannot > tell the correct way to address a pixel within that bitmap !! >Now: >a. Did we miss an important part in any doc ? Yes, you did. Bitmap bits are padded right to the next double-word boundary. >b. Number of bytes per scan-line, any idea? Use this formula (from the documentation) to calculate the number of bytes per scanline needed: HBITMAP hbmImage; BITMAPINFOHEADER bihInfo; /* Use BITMAPINFOHEADER2 if 32-bit app */ ULONG ulSzBuf; GpiQueryBitmapParameters(hbmImage,&bihInfo); ulSzBuf=(((bihInfo.cBitCount*bihInfo.cx)+31L)/32L)*4L*bihInfo.cPlanes; If you have any questions, send me email. Cheers, Q -- "If you choose not to decide, you | "My other body is in the shop" - seen still have made a choice" - Rush | on a T-shirt ------------------------------------------------------------------------
Technical Details
Message-ID:
<C17not.Cpq@panix.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!pipex!doc.ic.ac.uk!agate!usenet.ins.cwru.edu!gatech!news.ans.net!cmcl2!panix!os2manReferences:
<1993Jan21.083211.3396@neptune.inf.ethz.ch>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!doc.ic.ac.uk!agate!usenet.ins.cwru.edu!gatech!news.ans.net!cmcl2!panix!os2man From: os2man@panix.com (Larry Salomon Jr.) Subject: Re: Problem: Nasty Bitmaps Message-ID: <C17not.Cpq@panix.com> Organization: PANIX Public Access Unix, NYC References: <1993Jan21.083211.3396@neptune.inf.ethz.ch> Date: Thu, 21 Jan 1993 15:43:41 GMT Lines: 54