📄 show.c
字号:
seGetResolution((unsigned *) &x, (unsigned *) &y);
printf( ": %d * %d * %d Bpp\n", x, y, BitsPerPixel );
switch (seGetSwivelViewMode())
{
case ROTATE90:
// xOffset is the extra number of horizontal pixels needed
// to adjust for register dword alignment (if there is no
// misalignment, xOffset == 0).
xOffset = (seGetBytesPerScanline() * 8 / BitsPerPixel) - x;
break;
default:
xOffset = 0;
}
if ( gnUseVertical )
{
RepeatC = 8 / BitsPerPixel + 1;
for (i = 0; i < x; i++)
{
seDrawLine(i + xOffset, 1, i + xOffset, y-1, Color);
if (i % RepeatC == 0 )
Color = GetNextColor( Color, BitsPerPixel );
}
}
else
{
switch (BitsPerPixel)
{
case 1:
x_step = ((x - 2) * BPP_FACTOR) /2;
y_step = ((y - 2) * BPP_FACTOR);
Last_Cx2 = 0;
Cy2 = Last_Cy2 = 0;
for ( j = 0; j < 2; j++ )
{
Cx1 = (int)(((j * x_step) / BPP_FACTOR) + 1);
Cx2 = (int)((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int)((BPP_ROUNDUP / BPP_FACTOR) + 1);
Cy2 = (int)(((y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cx2 >= Cx1)
Cx1 = Last_Cx2+1;
Last_Cx2 = Cx2;
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1 + xOffset, Cy1, Cx2 + xOffset, Cy2, Color, 1);
Color = GetNextColor( Color, BitsPerPixel );
}
break;
case 2:
x_step = ((x - 2) * BPP_FACTOR) /2;
y_step = ((y - 2) * BPP_FACTOR) /2;
Cy2 = Last_Cy2 = 0;
for ( i = 0; i < 2; i++ )
{
Last_Cx2 = 0;
for ( j = 0; j < 2; j++ )
{
Cx1 = (int)(((j * x_step) / BPP_FACTOR) + 1);
Cx2 = (int)((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int)(((i * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy2 = (int)((((i + 1) * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cx2 >= Cx1)
Cx1 = Last_Cx2+1;
Last_Cx2 = Cx2;
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1 + xOffset, Cy1, Cx2 + xOffset, Cy2, Color, 1);
Color = GetNextColor( Color, BitsPerPixel );
}
Last_Cy2 = Cy2;
}
break;
case 4:
x_step = ((x - 2) * BPP_FACTOR) /4;
y_step = ((y - 2) * BPP_FACTOR) /4;
Cy2 = Last_Cy2 = 0;
for ( i = 0; i < 4; i++ )
{
Last_Cx2 = 0;
for ( j = 0; j < 4; j++ )
{
Cx1 = (int)(((j * x_step) / BPP_FACTOR) + 1);
Cx2 = (int)((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int)(((i * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy2 = (int)((((i + 1) * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cx2 >= Cx1)
Cx1 = Last_Cx2+1;
Last_Cx2 = Cx2;
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1 + xOffset, Cy1, Cx2 + xOffset, Cy2, Color, 1);
Color = GetNextColor( Color, BitsPerPixel );
}
Last_Cy2 = Cy2;
}
break;
case 8:
x_step = ((x - 2) * BPP_FACTOR ) /32;
y_step = ((y - 2) * BPP_FACTOR ) /8;
Cy2 = Last_Cy2 = 0;
for (i = 0; i < 8; i++)
{
Last_Cx2 = 0;
for (j = 0; j < 32; j++)
{
Cx1 = (int)(((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int)((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int)(((i * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy2 = (int)((((i + 1) * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cx2 >= Cx1)
Cx1 = Last_Cx2+1;
Last_Cx2 = Cx2;
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1 + xOffset, Cy1, Cx2 + xOffset, Cy2, Color, 1);
Color = GetNextColor( Color, BitsPerPixel );
}
Last_Cy2 = Cy2;
}
break;
case 16:
/*
* Subtract 2 from x and y so that I don't overwrite
* the borders. Multiply by BPP_FACTOR for more digits of
* precision. Add BPP_ROUNDUP to round up from the
* give number of digits of precision.
*/
/*green*/
Color = 0x20;
x_step = ((x-2) * BPP_FACTOR) /64;
y_step = ((y-2) * BPP_FACTOR) /3;
Color = 0;
Cx2 = 0;
Cy2 = 0;
for (j = 0; j < 64; j++)
{
Cx1 = (int) (((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int) ((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = 1;
Cy2 = (int) ((y_step / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
seDrawRect(Cx1 + xOffset, Cy1, Cx2 + xOffset, Cy2, Color, 1);
Color = GetNextColor(Color,BitsPerPixel);
}
Last_Cy2 = Cy2;
/* blue */
x_step = ((x-2)*BPP_FACTOR)/32; /* keep one digit of precision */
Color = 0;
Cx2 = 0;
for (j = 0; j < 32; j++)
{
Cx1 = (int) (((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int) ((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int) ((y_step / BPP_FACTOR) + 1);
Cy2 = (int) (((y_step * 2 + BPP_ROUNDUP) / BPP_FACTOR) + 1);
if (j == 1)
Color = 0x0001;
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1 + xOffset, Cy1, Cx2 + xOffset, Cy2, (DWORD) Color, 1);
Color = GetNextColor(Color,BitsPerPixel);
}
/*red*/
Color = 0;
Cx2 = 0;
Last_Cy2 = Cy2;
for (j = 0; j < 32; j++)
{
Cx1 = (int) (((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int) ((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int) ((2 * y_step + BPP_ROUNDUP)/BPP_FACTOR + 1);
Cy2 = (int) (((3 * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
if (j == 1)
Color = 0x0800;
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1 + xOffset, Cy1, Cx2 + xOffset, Cy2, Color, 1);
Color = GetNextColor(Color,BitsPerPixel);
}
break;
}
}
/*
** Draw border
*/
seDrawRect(0 + xOffset, 0, x-1 + xOffset, y-1, White, FALSE);
if (gnShowGrid)
{
/*
** Draw vertical lines
*/
for (Cx1 = 0; Cx1 < x; Cx1 += 20)
seDrawLine(Cx1 + xOffset, 0, Cx1 + xOffset, y-1, GridColor);
/*
** Draw horizontal lines
*/
for (Cy1 = 0; Cy1 < y; Cy1 += 20)
seDrawLine(0 + xOffset, Cy1, x-1 + xOffset, Cy1, GridColor);
}
/* Arrow pointing to top of screen */
seDrawLine(x/2 + xOffset, 0, (x/2)-10 + xOffset, 10, White);
seDrawLine(x/2 + xOffset, 0, (x/2)+10 + xOffset, 10, White);
seDrawLine((x/2)-10 + xOffset, 10, (x/2)+10 + xOffset, 10, White);
}
/*-------------------------------------------------------------------------*/
unsigned GetNextColor( unsigned Color, unsigned BPP )
{
unsigned NewColor;
unsigned Red,Green,Blue;
switch (BPP)
{
case 1:
return ((++Color) & 0x01);
break;
case 2:
return ((++Color) & 0x03);
break;
case 4:
return ((++Color) & 0x0F);
break;
default:
case 8:
return ((++Color) & 0xFF);
break;
case 16:
if (!Color)
NewColor = Color + 0x20;
else
{
Red = Color & 0xf800;
Green = Color & 0x07e0;
Blue = Color & 0x1f;
if (Red)
{
Red = (Red + 0x0800) & 0xf800;
if (!Red)
Green += 0x20;
}
else if (Green)
{
Green = (Green + 0x20) & 0x07e0;
if (!Green)
Blue += 1;
}
else if (Blue)
{
Blue = (Blue + 1) & 0x1f;
if (!Blue)
Red +=0x0800;
}
NewColor = Red | Green | Blue;
}
return NewColor;
}
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -