
Technical Updates SNBC CONFIDENCIAL
Shandong New Beiyang Information Technology Co.,Ltd.
Page 50
const int nPixelsOfHeight
,
char *pBmpDataRotated
)
{
// Define process variables
int nBytesOfWidth = 0
,
nBytesOfHeight = 0;
int
i=0
,
col=0
,
row=0
,
index = 0
,
colbyte = 0;
char*
midData;
unsigned char tempdata = 0
,
colnum = 0
,
rownum = 0;
unsigned char temp[8] = {0x80
,
0x40
,
0x20
,
0x10
,
0x08
,
0x04
,
0x02
,
0x01};
// Comparing parameters
if (pBmpData == NULL || pBmpDataRotated == NULL) return 0;
if (nPixelsOfWidth <= 0 || nPixelsOfHeight <= 0) return 0;
if ((nPixelsOfWidth % 8) != 0 || (nPixelsOfHeight % 8) != 0) return 0;
// get real image dimension
nBytesOfWidth = (nPixels31)/32*4;
nBytesOfHeight = nPixelsOfHeight / 8;
// White/black reverse
,
the value 1 in BMP data is for white which is contrary to the printer definition.
midData = (char*)malloc(nBytesOfWidth*nPixelsO1);
for(i=0;i<nBytesOfWidth*nPixelsOfHeight;i++){midData[i] = 0xff-pBmpData[i];}
// Rotation. BMP data is arranged in line data type while data downloaded to printer are arranged in
column data type.
for (row = 0; row <nPixelsOfWidth; row++){
for (colbyte = 0; colbyte < nBytesOfHeight; +){
index = row * nBytesOf colbyte;
pBmpDataRotated[index] = 0x00;
for (col = 0; col < 8; col++){
colnum = col % 8;
rownum = row % 8;
if(colnum
>=
rownum)
tempdata
=
temp[col]
&
(midData[(nPixelsOfHeight-1-colbyte*8-col) *
nBytesO row / 8] >> (colnum-rownum));
else
tempdata
=
temp[col]
&
(midData[(nPixelsOfHeight-1-colbyte*8-col) *
nBytesO row / 8] << (rownum-colnum));
pBmpDataRotated[index] |= tempdata;
}
}
}
// release interim buffers
free(midData);
return 1;