Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

need a faster way to draw image

Posted on 1999-01-25
4
Medium Priority
?
196 Views
Last Modified: 2013-12-26
i'm opening a gif and drawing it to the screen one pixel at a time.
even drawing in an offscreen pixmap is painfully slow.
is there a way to poke values directly to a pixmap ?
perhaps load an array of values and use blockMove or something ?
i'm using think c 5.0.4
( yes i know it's time to switch to code warrior )
thanks
0
Comment
Question by:jabes012399
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:roov
ID: 1291762
As I recall (and forgive me if I'm wrong) GIFs are run-length-encoded. In such a case, I've seen drastic improvments when in stead setting one pixel at a time you use MoveTo() and LineTo(). In my case, it was a 600% improvement.
0
 

Author Comment

by:jabes012399
ID: 1291763
This actually slows it down more
for me.  Perhaps this question needs to be restated:

Does anyone know how programs like "JPEGView" are able to decode and draw
gif files so quickly ?  I have QuickTime disabled and the offscreen bitmap
option is set to "Never created".  So that leads me to believe that it's
not using QuickTime or offscreen bitmaps.  Yet it amazes me how fast it's
able to draw.  I'm able to decode a gif file rather quickly but still am at
a loss on how to draw it as fast as JPEGView.
0
 
LVL 3

Accepted Solution

by:
boonstra earned 200 total points
ID: 1291764
You haven't shown us your GIF decoding code, so it is possible that part of the problem lies there.  However, you certainly want to access the PixMap memory directly after you have decoded the GIF.  Directly setting the pixels in a tight loop will certainly be faster than using a trap like SetCPixel, or even a QuickDraw routine like LineTo.

JPEGView and other GIF decoders take advantage of the fact that a GIF can by design contain only 256 colors, meaning that the PixMap pixelSize can be set to one byte per pixel.  This allows the byte associated with the pixel at (row,col) to be accessed as:
  *(pm->baseAddr + row*pm->rowBytes + col),
where pm is a PixMapPtr.  For the last ounce of speed, you might also consider coding your innermost loops in assembly language.

Stored at this address is the index of the color in pm->colorTable.

There is much sample code associated with blasting (or "blitting") values to a PixMap.  Among the ones you might want to look at are:

<ftp://dev.apple.com/developer/Sample_Code/Snippets/QuickDraw/Out_of_This_GWorld.sit.hqx>
<ftp://dev.apple.com/developer/Sample_Code/Snippets/QuickDraw/Direct_Pixel_Access.sit.hqx>
<ftp://dev.apple.com/developer/Sample_Code/Snippets/QuickDraw/CopyBits_vs._CopyMask.sit.hqx>
<ftp://dev.apple.com/developer/Sample_Code/QuickDraw/OffSample.sit.hqx>

You can certainly also use BlockMove (or BlockMoveData) to blast data to your PixMap.  But you still would need to move it to an Offscreen PixMap first, which uses the same techniques described above.  For CopyBits insights, you could look (among other places) in the back issues of (shameless plug) MacTech, like:
<http://www.mactech.com/articles/develop/issue_18/043-054_Othmer_REV.html>

Hope this helps.
0
 

Author Comment

by:jabes012399
ID: 1291765
Although I was not able to solve
my problem via the information
submitted by boonstra,  I'm sure the answer does lie there somewhere.  Plus there are some good code examples.  After days of struggling to get it to work,  I went back to a snippet of code that was sent to me from comp.sys.mac.programmer.help and after some reworking of the code, i finally got it to go.

Results are impressive.

I'll post the code if anyone is interested.

-jabes
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question