📄 bits7.c
字号:
fSrcDX = (float) srcDltX / (float) dstDltX; /* macro pix width =
src width / dst width */
fDstDX = 1; /* dst macro pix width = 1.0 */
}
else
{
fDstDX = (float) dstDltX / (float) srcDltX; /* macro pix width =
dst width / src width */
fSrcDX = 1; /* src macro pix width = 1.0 */
}
/* set source and destination "macro pixel" variables for Y */
if (srcDltY > dstDltY)
{
fSrcDY = (float) srcDltY / (float) dstDltY; /* macro pix height =
src height / dst height */
fDstDY = 1; /* dst macro pix height = 1.0 */
}
else
{
fDstDY = (float) dstDltY / (float) srcDltY; /* macro pix height =
dst height / src height */
fSrcDY = 1; /* src macro pix height = 1.0 */
}
/* initialize src and dest Ymin and Ymax */
SrcYmin = GsrcRect.Ymin;
fSrcYmin = SrcYmin;
fSrcYmax = fSrcYmin + fSrcDY;
SrcYmax = (short) fSrcYmax;
DstYmin = GdstRect.Ymin;
fDstYmin = DstYmin;
fDstYmax = fDstYmin + fDstDY;
DstYmax = (short) fDstYmax;
/* ============= Actual ZOOM loop ======================= */
/* spread each src "macro pix" row on each dest "macro pix row" */
while ( SrcYmax <= GsrcRect.Ymax)
{
SrcXmin = GsrcRect.Xmin;
fSrcXmin = SrcXmin;
fSrcXmax = fSrcXmin + fSrcDX;
SrcXmax = (short) fSrcXmax;
DstXmin = GdstRect.Xmin;
fDstXmin = DstXmin;
fDstXmax = fDstXmin + fDstDX;
DstXmax = (short) fDstXmax;
while ( SrcXmax <= GsrcRect.Xmax)
{
/* ZOOM by filling the destination macro pixel with the source color */
/* first thing to check is if we're zooming up or down */
/* Note: this must be re-calculated each time */
/* if either the height or width of the source "macro pixel" is
greater than 1, we are Zooming Down else, we're Zooming Up */
if (( SrcXmax - SrcXmin + SrcYmax - SrcYmin) <= 2)
{ /* =================== zoom up ========================== */
/* spread 1 source pixel to multiple destination pixels */
tmpColor = (srcPORT->portMap->prGetPx)(SrcXmin, SrcYmin,
blitRec.blitSmap);
}
else
{
/* =================== zoom down ========================== */
switch (ZoomDnVect)
{
case Zoom_Down_Color:
/* Color Zoom Down (monochrome, 16, and 256) tallies each
pixel's color in the source "macro pixel", and the color
with the most pixels is the predominant color */
for (i = 0; i <= NColors; i++) /* clear color array */
{
colorCnt[i] = 0;
}
maxColorCnt = 0; /* zero out max color count */
while (SrcYmin <= SrcYmax) /* start at first row */
{
/* BobB 11/3/99 - added the following line since SrcXmin is incremented */
SrcXmin = (short) fSrcXmin;
while (SrcXmin <= SrcXmax) /* start at first column */
{
tmpColor = ((blitRec.blitSmap->prGetPx)
(SrcXmin, SrcYmin, blitRec.blitSmap)) & 0xff;
SrcXmin++; /* inc column */
if (!(srcMode & 0x0010) || (srcBack != tmpColor))
{ /* check if src using transparency and color
is back color */
colorCnt[tmpColor]++; /* add to total for that
color index */
if (maxColorCnt < colorCnt[tmpColor])
{ /* is this the new max color */
maxColorCnt = colorCnt[tmpColor];
/* BobB 5/5/98 - corrected the following line to get rid of a compiler warning
maxColor = tmpColor; */
maxColor = (unsigned short) tmpColor;
}
}
}
SrcYmin++; /* next row */
}
if (maxColorCnt == 0) /* special check of if count is 0 */
{ /* transparnt src, all pixels backcolor */
tmpColor = srcBack; /* set color to source backcolor */
}
else
{
tmpColor = maxColor; /* set color to source max color */
}
break;
case Zoom_Down_RGB:
/* RGB Zoom Down (greater than 255) adds all of the Reds,
Greens, and Blues for each pixel in the source "macro pixel",
and divides by number of pixels in the source "macro pixel"
to get the average */
redColorCnt = 0; /* zero Red value count */
greenColorCnt = 0; /* zero Green value count */
blueColorCnt = 0; /* zero Blue value count */
/* BobB 11/3/99 - moved the following lines to here */
/* build the average RGB value from the total Red, Green,
and Blues */
totalPixels = (1 + (SrcXmax - SrcXmin)) *
(1 + (SrcYmax - SrcYmin));
while (SrcYmin <= SrcYmax) /* start at first row */
{
/* BobB 11/3/99 - added the following line since SrcXmin is incremented */
SrcXmin = (short) fSrcXmin;
while (SrcXmin <= SrcXmax) /* start at first column */
{
/* BobB 5/5/98 - corrected the following line to get rid of a compiler warning
RGBrtn = ((blitRec.blitSmap->prGetPx) */
RGBrtn = (unsigned short) ((blitRec.blitSmap->prGetPx)
(SrcXmin, SrcYmin, blitRec.blitSmap));
/* mask off red bits and add to running total */
redColorCnt += ((RGBrtn & Rmask) >> Rshift);
/* mask off green bits and add to running total */
greenColorCnt += ((RGBrtn & Gmask) >> Gshift);
/* mask off blue bits and add to running total */
blueColorCnt += ((RGBrtn & Bmask) >> Bshift);
SrcXmin++; /* inc column */
}
SrcYmin++; /* next row */
}
/* BobB 11/3/99 - moved the following lines from here */
/* build the average RGB value from the total Red, Green,
and Blues */
/* totalPixels = (1 + (SrcXmax - SrcXmin)) *
(1 + (SrcYmax - SrcYmin)); */
/* BobB 5/5/98 - corrected the following three lines to get rid of compiler warnings
redColorCnt /= totalPixels;*/ /* average red count */
/* greenColorCnt /= totalPixels;*/ /* average green count */
/* blueColorCnt /= totalPixels;*/ /* average blue count */
redColorCnt /= (short) totalPixels; /* average red count */
greenColorCnt /= (short) totalPixels; /* average green count */
blueColorCnt /= (short) totalPixels; /* average blue count */
tmpColor = (redColorCnt << Rshift) | (greenColorCnt <<
Gshift) | (blueColorCnt << Bshift);
}
/* =============== now do fill ==========================*/
if (NColors == 1) /* is the source is monochrome ? */
{
/* color translate by seeing if source bit is off */
if (tmpColor > 0) /* back color ? */
{
tmpColor = dstPen;
}
else
{
if (blitRec.blitRop & 0x0010) /* is dest transparent ? */
{
goto Sprd_NextX;/* if so, don't do fill */
}
tmpColor = dstBack; /* fill with dst back color */
}
}
}
blitRec.blitFore = tmpColor;
dstBR.Xmin = DstXmin; /* get global pixel values */
dstBR.Ymin = DstYmin; /* and set it into blitRcd */
dstBR.Xmax = DstXmax;
dstBR.Ymax = DstYmax;
(blitRec.blitDmap->prFill)(&blitRec); /* draw the output rect */
Sprd_NextX:
fSrcXmin += fSrcDX; /* add src "macro pix" width */
SrcXmin = (short) fSrcXmin;
fSrcXmax += fSrcDX;
SrcXmax = (short) fSrcXmax;
fDstXmin += fDstDX; /* add dst "macro pix" width */
DstXmin = (short) fDstXmin;
fDstXmax += fDstDX;
DstXmax = (short) fDstXmax;
}
fSrcYmin += fSrcDY; /* add src "macro pix" height */
SrcYmin = (short) fSrcYmin;
fSrcYmax += fSrcDY;
SrcYmax = (short) fSrcYmax;
fDstYmin += fDstDY; /* add dst "macro pix" height */
DstYmin = (short) fDstYmin;
fDstYmax += fDstDY;
DstYmax = (short) fDstYmax;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -