Thread: iLiad Fixing iPdf for iRex
View Single Post
Old 12-12-2006, 09:59 PM   #14
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
Version 7.

Centered pages.
Working zoom.
Less useless debug messages so its faster.

Code for iRex...

Code:
void XMgr::drawImage(SplashBitmap * bmp, 
                     int xSrc , int ySrc , 
                     int xDest, int yDest) 
{
    // Get our source image width and calculate delta frem screen width
    int srcWidth = bmp->getWidth();
    int deltaX = SCREEN_WIDTH - srcWidth;
    if (deltaX < 0) {
      // Source too wide, trim to screen width
      srcWidth = SCREEN_WIDTH;
    }

    // Get our source image height and calculate delta frem screen height
    int srcHeight = bmp->getHeight();
    int deltaY = CLIENT_AREA - (srcHeight + yDest);
    if (deltaY < 0) {
      // Source too tall, trim to screen height
      srcHeight = CLIENT_AREA - yDest;
    }

    // Get src image pointer from SplashBitmap
    char *src = (char*)bmp->getDataPtr();

    // Handle partial bitmap (zoom)
    if (xDest < 0) {
      // Outdent left margin
      src -= xDest;
    }
    if (yDest < 0) {
      // Skip down image
      src -= yDest * bmp->getWidth();;
    }

    // Point to screen memory buffer
    char *dest = screenMem;

    // Fill page header with white
    if (yDest > 0) {
      memset(dest, 0xf0, yDest * SCREEN_WIDTH);
      dest += yDest * SCREEN_WIDTH;
    }

    // Fill left margin
    if (xDest > 0) {
      memset(dest, 0xf0, xDest);
      dest += xDest;
    }

    // Copy rows from image to screen
    for (int i = 0; i < srcHeight; i++) {
      // Copy source line of data
      memcpy(dest, src, srcWidth);
      src += srcWidth;
      dest += srcWidth;

      // Fill right/left margin with white
      if (deltaX > 0) {
        memset(dest, 0xf0, deltaX);
        dest += deltaX;
      } else {
        // Skip extra source line material
        src -= deltaX;
      }
    }

    // Fill bottom of page with white
    if (deltaY > 0) {
      memset(dest, 0xf0, deltaY * SCREEN_WIDTH);
    }
}
Attached Files
File Type: gz ipdf_v7.tar.gz (18.7 KB, 505 views)
scotty1024 is offline   Reply With Quote