Skip to content

Commit

Permalink
added user pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Bank authored and Laurence Bank committed Jul 24, 2022
1 parent eef1b44 commit 834e981
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/TIFF_G4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ int TIFFG4::drawIcon(float scale, int iSrcX, int iSrcY, int iSrcWidth, int iSrcH
return Decode(&_tiff);
} /* drawIcon() */

//
// set draw callback user pointer variable
//
void TIFFG4::setUserPointer(void *p)
{
_tiff.pUser = p;
}

void TIFFG4::setDrawParameters(float scale, int iPixelType, int iStartX, int iStartY, int iWidth, int iHeight, uint8_t *p4BPPBuf)
{
_tiff.window.iScale = (uint32_t)(scale * 65536.0f); // convert to uint32
Expand Down
3 changes: 3 additions & 0 deletions src/TIFF_G4.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef struct tiff_draw_tag
int iScaledWidth, iScaledHeight; // width & height of the scaled region
int iWidth, iHeight; // size of entire image in pixels
int iDestX, iDestY; // destination coordinates on output
void *pUser; // user pointer
uint8_t *pPixels; // 1, 2 or 16-bit pixels (for drawIcon)
uint8_t ucPixelType, ucLast;
} TIFFDRAW;
Expand Down Expand Up @@ -117,6 +118,7 @@ typedef struct tiff_image_tag
TIFF_CLOSE_CALLBACK *pfnClose;
TIFFFILE TIFFFile;
TIFFWINDOW window;
void *pUser;
uint16_t usFG, usBG; // RGB565 colors for drawIcon()
int16_t CurFlips[MAX_IMAGE_WIDTH];
int16_t RefFlips[MAX_IMAGE_WIDTH];
Expand All @@ -137,6 +139,7 @@ class TIFFG4
void close();
void setDrawParameters(float scale, int iPixelType, int iStartX, int iStartY, int iWidth, int iHeight, uint8_t *p4BPPBuf);
int drawIcon(float scale, int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDstX, int iDstY, uint16_t usFGColor, uint16_t usBGColor);
void setUserPointer(void *p);
int decode(int iDstX=0, int iDstY=0);
int getWidth();
int getHeight();
Expand Down
3 changes: 2 additions & 1 deletion src/tiffg4.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ static void Scale2Color(TIFFIMAGE *pPage, int width)
ulBG = pPage->usBG | ((uint32_t)pPage->usBG << 16);
ulFG &= ulClrMask; ulBG &= ulClrMask;

pConvert = (pPage->window.iScale >= 65536) ? ulClrConvert1 : ulClrConvert0;
pConvert = (pPage->window.iScale >= 65536) ? (uint32_t *)ulClrConvert1 : (uint32_t *)ulClrConvert0;
dest = source = pPage->ucPixels; // write the new pixels over the old to save memory
// Convert everything to 2-bpp grayscale first
for (x=0; x<width/8; x+=2) /* Convert a pair of lines to gray */
Expand Down Expand Up @@ -806,6 +806,7 @@ static int TIFFDrawLine(TIFFIMAGE *pPage, int y, int16_t *pCurFlips)
obgd.iDestY = pPage->window.dsty;
obgd.iScaledWidth = (pPage->window.iWidth * u32ScaleFactor) >> 16;
obgd.iScaledHeight = (pPage->window.iHeight * u32ScaleFactor) >> 16;
obgd.pUser = pPage->pUser;
iStart = pPage->window.x;

if (y >= pPage->window.y + pPage->window.iHeight)
Expand Down

0 comments on commit 834e981

Please sign in to comment.