I can't comment on the error, but I have displayed images larger than
160x160. I grab screen shots out of a test instrument which are 320x240
mono Windows BMPs. I then display them either scaled down to 160x120 or
in a scrollable 1:1 view in the same 160x120 window.
I basically create a Bitmap using the WindBmp routines used in some of
the SDK samples (ex. Beamer). The BMP is 160x120. I then index over
the bitmap header and render the data into the bitmap just before I draw
it. My data is stored in an MemPtrNew allocated pointer (320x240 mono
is 9600 bytes). I don't render directly from a Dm record because I
compress the data when it's acquired. I decompress the record when the
viewer form is loaded and free the allocated memory when the form is
unloaded.
To keep things simple, I only allow horizontal scrolling on byte (8
pixels in mono) boundaries. The rendering is plenty fast (scrolling is
responsive, etc.) I did it this way so the OS is never being asked to
doing anything unusual (no negative offsets, no unusually large sizes,
etc.)
The render routine is below. Note, the scaler is cheesy, it does not
anti-alias on either axis, it just de-emph's diagonals. If you need
better mono (or gray scale) scaling, let me know.
Good Luck
-jjf
static void RenderImage(Byte *src, // 320x240 mono source
data
BitmapPtr bmpP, // 160x120 mono bitmap ptr
Word style, // 0=whole image,
<>0=1:1
Word xoff, // x offset in 8bit
units (0-20)
Word yoff) // y offset in
lines (0-120)
// Note: x&y
only go from 0 to 1/2 since
// we don't want
to go past the right or
// bottom edges
of our source image
{
Int x, y; // For looping through the data
Byte *dst; // For accessing the data portion of the BMP
// Setup dest
dst = (Byte *)bmpP;
dst += sizeof(BitmapType);
// 1:1 view?
if (style)
{
// Use the offset to find the starting point in the
original
src += (yoff * 40) + xoff;
// Copy a row at a time
for (y = 0 ; y < 120 ; y++)
{
// Copy 8 pixels at a time
for (x = 0 ; x < 20 ; x++)
*(dst++) = *(src++);
// We only used 160 of the 320 pixes in the
source row
// So jump 160 pixels forward to the starting
point of
// the next line
src += 20;
}
}
else // Full view
{
// No offsets, since we use the entire original
// Again, a row at a time
for (y = 0 ; y < 120 ; y++)
{
// Build 8 pixels at a time
for (x = 0 ; x < 20 ; x++)
{
// Start at 0, OR in results of
// 2:1 scaling
*dst = 0;
// Build 1 byte from 4
// 2 hor or 2 ver, yes, otherwise no
if ((src[0] & 0xC0) || (src[40] & 0xC0))
*dst |= 0x80;
if ((src[0] & 0x30) || (src[40] & 0x30))
*dst |= 0x40;
if ((src[0] & 0x0C) || (src[40] & 0x0C))
*dst |= 0x20;
if ((src[0] & 0x03) || (src[40] & 0x03))
*dst |= 0x10;
if ((src[1] & 0xC0) || (src[41] & 0xC0))
*dst |= 0x8;
if ((src[1] & 0x30) || (src[41] & 0x30))
*dst |= 0x4;
if ((src[1] & 0x0C) || (src[41] & 0x0C))
*dst |= 0x2;
if ((src[1] & 0x03) || (src[41] & 0x03))
*dst |= 0x1;
// Next target byte to build
dst++;
// Next 2 source bytes to use
src+=2;
}
// Skip a source line, since we use two source
lines every pass
src+=40;
}
}
}
-----Original Message-----
From: Chuck Atwood [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 28, 2000 2:30 PM
To: Palm Developer Forum
Subject: Re: displaying large grayscale graphics
I wrote some code that did panning on a large bitmap using the method
described below. It works fine under POSE. However, when I downloaded
it to
my Palm V I get the following RESET error: ScrDriverNew.c line 500
Invalid
Params. I just ordered my source code, but can someone give me some
insight
while I'm waiting two weeks. I.e. are negatives not allowed in some
versions
of the OS (my Palm V is 3.1.1) or is some other parameter being checked.
TIA-chuck
Bob Ebert wrote:
> At 7:27 PM +0100 20-01-00, Jeffrey Hall wrote:
> >me, because I'd like to try to support scrolling. I
> >don't really understand how to draw an image to the
> >display if the image is larger than 160 x 160. Could
> >you point me towards some information that I could
> >read on how to do this?
>
> WinDrawBitmap should also work, if you just pass the appropriate
(offset)
> coordinates for the x,y. (That is, you may have to pass negative x
and y
> values.) The window will clip the bitmap so it fits.
>
> Or, you could use WinCreateBitmapWindow on your larger-than-the-screen
> bitmap, and then use WinCopyRectangle to copy a portion of it to the
> screen. WinCopyRectangle gives you more control over which portion is
> drawn.
>
> --Bob
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html