Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Codewarrior Palm > Re: Using other...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 6 Topic 651 of 719
Post > Topic >>

Re: Using other heaps for memory...if I run out?

by Logan Shaw <lshaw-usenet@[EMAIL PROTECTED] > Sep 7, 2005 at 10:41 PM

userforgroups@[EMAIL PROTECTED]
 wrote:
> Thanks for the info Logan.  Here's basically my problem.  My dynamic
> heap usage is fairly small, somewhere around 50k or so.  The real issue
> is the creation of my two window buffers.  Of course on a hi-res device
> (320x320) each is 204k, so there goes a huge heap of heap :)
> 
> The reason I do this, is that there is a complex background that I like
> to keep in a "clean" state at all times, thus one of the buffers.  Then
> I draw what I need when I need it to the second buffer.  When something
> drastic changes and I need to redraw the whole thing, I just transfer
> the buffer from the first "clean" image to the other buffer, then add
> my other "dynamic" elements.  Now I could just keep the other as a
> bitmap resource and do a regular windrawbitmap to the one buffer, but I
> have a second requirement.
> 
> I might only be updating or clearing a small area at a time during
> normal operation. Small areas, maybe 20x20 pixels, and in order to
> clear them I basically do a wincopyrectangle from the orginal "clean"
> image, to the area I need to clear.  So this is why I needed the second
> buffer.

It seems like you could solve this problem without having a background
buffer.

You should be able to take a bitmap that is in a resource, lock the
resource, and use WinCreateBitmapWindow() to make a window wrapper
around it.  Then you should be able to use WinCopyRectangle() to copy
parts of it to your buffer that you use to update all or part of the
screen.

There are probably some gotchas with this approach.  One is that you
don't want to make the bitmap resource compressed, because that will
slow down copying.  Another is that resources cannot be bigger than
64K, so you will have to break the original into tiles (or bands),
which makes copying it to your screen update buffer more complicated.
The last is that you really want your bitmap to have the same depth
as the screen, so that could be a little tricky.  But, it should be
possible, with care, to overcome all these problems.

A different approach is to just allocate some memory in the storage
heap.  This memory can't be written to in the normal manner, and
you must use DmWrite() to write to it, but you can read from it just
like any other memory (it is addressable).  So, you could do some
sequence like this:

(1)  Start your app.
(2)  Allocate one big buffer in dynamic heap.
(3)  Build your background in that buffer.
(4)  Allocate memory from the storage heap using a feature pointer
      (FtrPtrNew()).
(5)  Copy the background into the feature memory with DmWrite().
(6)  Re-purpose your big buffer (in dynamic heap) as a display-update
      buffer.

Just how much memory is available in the storage heap depends on
what the user has installed (since PRCs and PDBs go there), but
on a blank device, there is always more space in the storage heap
than the dynamic heap.

And, by the way, I agree that these limitations are kinda crazy.  But,
considering that the original device had only 128K, they're not that
surprising...

   - Logan
 




 6 Posts in Topic:
Using other heaps for memory...if I run out?
userforgroups@[EMAIL PROT  2005-09-06 19:30:11 
Re: Using other heaps for memory...if I run out?
Logan Shaw <lshaw-usen  2005-09-07 03:46:00 
Re: Using other heaps for memory...if I run out?
userforgroups@[EMAIL PROT  2005-09-07 09:29:48 
Re: Using other heaps for memory...if I run out?
Logan Shaw <lshaw-usen  2005-09-07 22:41:05 
Re: Using other heaps for memory...if I run out?
userforgroups@[EMAIL PROT  2005-09-07 12:23:14 
Re: Using other heaps for memory...if I run out?
Logan Shaw <lshaw-usen  2005-09-07 22:46:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 22:57:22 CDT 2008.