Back to index

lightning-sunbird  0.9+nobinonly
Functions
imgScaler.cpp File Reference
#include <stdlib.h>
#include <stdio.h>
#include "imgScaler.h"

Go to the source code of this file.

Functions

static void Stretch32 (unsigned x1, unsigned x2, unsigned y1, unsigned y2, unsigned yr, unsigned yw, unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn, unsigned char *aSrcImage, unsigned aSrcStride, unsigned char *aDstImage, unsigned aDstStride)
static void Stretch24 (unsigned x1, unsigned x2, unsigned y1, unsigned y2, unsigned yr, unsigned yw, unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn, unsigned char *aSrcImage, unsigned aSrcStride, unsigned char *aDstImage, unsigned aDstStride)
static void Stretch8 (unsigned x1, unsigned x2, unsigned y1, unsigned y2, unsigned yr, unsigned yw, unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn, unsigned char *aSrcImage, unsigned aSrcStride, unsigned char *aDstImage, unsigned aDstStride)
static void Stretch1 (unsigned x1, unsigned x2, unsigned y1, unsigned y2, unsigned yr, unsigned yw, unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn, unsigned char *aSrcImage, unsigned aSrcStride, unsigned char *aDstImage, unsigned aDstStride)
 RectStretch (unsigned aSrcWidth, unsigned aSrcHeight, unsigned aDstWidth, unsigned aDstHeight, unsigned aStartColumn, unsigned aStartRow, unsigned aEndColumn, unsigned aEndRow, unsigned char *aSrcImage, unsigned aSrcStride, unsigned char *aDstImage, unsigned aDstStride, unsigned aDepth)

Function Documentation

RectStretch ( unsigned  aSrcWidth,
unsigned  aSrcHeight,
unsigned  aDstWidth,
unsigned  aDstHeight,
unsigned  aStartColumn,
unsigned  aStartRow,
unsigned  aEndColumn,
unsigned  aEndRow,
unsigned char *  aSrcImage,
unsigned  aSrcStride,
unsigned char *  aDstImage,
unsigned  aDstStride,
unsigned  aDepth 
)

Definition at line 105 of file imgScaler.cpp.

{
    int e;
    unsigned dx, dy;
    void (*Stretch)(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
                  unsigned yr, unsigned yw,
                  unsigned aStartRow, unsigned aStartColumn,
                  unsigned aEndColumn,
                  unsigned char *aSrcImage, unsigned aSrcStride,
                  unsigned char *aDstImage, unsigned aDstStride);

    unsigned xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

    xs1 = ys1 = xd1 = yd1 = 0;
    xs2 = aSrcWidth  - 1;
    ys2 = aSrcHeight - 1;
    xd2 = aDstWidth  - 1;
    yd2 = aDstHeight - 1;

//    fprintf(stderr, "RS (%d %d)-(%d %d) (%d %d)-(%d %d) %d %d %d\n",
//         xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2,
//         aSrcStride, aDstStride, aDepth);

    switch (aDepth) {
    case 32:
       Stretch = Stretch32;
       break;
    case 24:
       Stretch = Stretch24;
       break;
    case 8:
       Stretch = Stretch8;
       break;
    case 1:
       Stretch = Stretch1;
       break;
    default:
       return;
    }
    dx = yd2 - yd1;
    dy = ys2 - ys1;
    e = dy - dx;
    dy += 1;
    if (!dx)
       dx = 1;
    for (yd1 = 0; yd1 <= aEndRow; yd1++) {
       if (yd1 >= aStartRow)
           Stretch(xd1, xd2, xs1, xs2, ys1, yd1,
                  aStartRow, aStartColumn, aEndColumn,
                  aSrcImage, aSrcStride, aDstImage, aDstStride);
       while (e >= 0) {
           ys1++;
           e -= dx;
       }
       e += dy;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Stretch1 ( unsigned  x1,
unsigned  x2,
unsigned  y1,
unsigned  y2,
unsigned  yr,
unsigned  yw,
unsigned  aStartRow,
unsigned  aStartColumn,
unsigned  aEndColumn,
unsigned char *  aSrcImage,
unsigned  aSrcStride,
unsigned char *  aDstImage,
unsigned  aDstStride 
) [static]

Definition at line 280 of file imgScaler.cpp.

{
    int e;
    unsigned dx, dy, d;

    dx = x2 - x1;
    dy = y2 - y1;
    e = dy - dx;
    dy += 1;
    if (!dx)
       dx = 1;
    for (d = 0; d <= aEndColumn; d++) {
       if ((d >= aStartColumn) &&
           (*(aSrcImage + yr * aSrcStride + (y1 >> 3)) & 1 << (7 - y1 & 0x7)))
           *(aDstImage +
             (yw - aStartRow) * aDstStride +
             ((x1 - aStartColumn) >> 3)) 
              |= 1 << (7 - x1 & 0x7);
       while (e >= 0) {
           y1++;
           e -= dx;
       }
       x1++;
       e += dy;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Stretch24 ( unsigned  x1,
unsigned  x2,
unsigned  y1,
unsigned  y2,
unsigned  yr,
unsigned  yw,
unsigned  aStartRow,
unsigned  aStartColumn,
unsigned  aEndColumn,
unsigned char *  aSrcImage,
unsigned  aSrcStride,
unsigned char *  aDstImage,
unsigned  aDstStride 
) [static]

Definition at line 215 of file imgScaler.cpp.

{
    int e;
    unsigned dx, dy, d;
    unsigned char *src, *dst;

    dx = x2 - x1;
    dy = y2 - y1;
    e = dy - dx;
    dy += 1;
    src = aSrcImage + yr * aSrcStride + 3 * y1;
    dst = aDstImage + (yw - aStartRow) * aDstStride;
    if (!dx)
       dx = 1;
    for (d = 0; d <= aEndColumn; d++) {
       if (d >= aStartColumn) {
           *dst++ = src[0];
           *dst++ = src[1];
           *dst++ = src[2];
       }
       while (e >= 0) {
           src += 3;
           e -= dx;
       }
       e += dy;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Stretch32 ( unsigned  x1,
unsigned  x2,
unsigned  y1,
unsigned  y2,
unsigned  yr,
unsigned  yw,
unsigned  aStartRow,
unsigned  aStartColumn,
unsigned  aEndColumn,
unsigned char *  aSrcImage,
unsigned  aSrcStride,
unsigned char *  aDstImage,
unsigned  aDstStride 
) [static]

Definition at line 181 of file imgScaler.cpp.

{
    int e;
    unsigned dx, dy, d;
    unsigned char *src, *dst;

    dx = x2 - x1;
    dy = y2 - y1;
    e = dy - dx;
    dy += 1;
    src = aSrcImage + yr * aSrcStride + 4 * y1;
    dst = aDstImage + (yw - aStartRow) * aDstStride;
    if (!dx)
       dx = 1;
    for (d = 0; d <= aEndColumn; d++) {
       if (d >= aStartColumn) {
           *dst++ = src[0];
           *dst++ = src[1];
           *dst++ = src[2];
           *dst++ = src[3];
       }
       while (e >= 0) {
           src += 4;
           e -= dx;
       }
       e += dy;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Stretch8 ( unsigned  x1,
unsigned  x2,
unsigned  y1,
unsigned  y2,
unsigned  yr,
unsigned  yw,
unsigned  aStartRow,
unsigned  aStartColumn,
unsigned  aEndColumn,
unsigned char *  aSrcImage,
unsigned  aSrcStride,
unsigned char *  aDstImage,
unsigned  aDstStride 
) [static]

Definition at line 248 of file imgScaler.cpp.

{
    int e;
    unsigned dx, dy, d;
    unsigned char *src, *dst;

    dx = x2 - x1;
    dy = y2 - y1;
    e = dy - dx;
    dy += 1;
    src = aSrcImage + yr * aSrcStride + y1;
    dst = aDstImage + (yw - aStartRow) * aDstStride;
    if (!dx)
       dx = 1;
    for (d = 0; d <= aEndColumn; d++) {
       if (d >= aStartColumn) {
           *dst = *src;
           dst++;
       }
       while (e >= 0) {
           src++;
           e -= dx;
       }
       e += dy;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: