1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
void DrawImageRectanglePoints(HDC DestinationHDC, Position3D[] Points, Size3D WorldSize) {
// Points(0) is the Upper-Left
// Points(1) is the Upper-Right
// Points(2) is the Low-Right
// Points(3) is the Low-Left
// Get left and right vertical line points:
Position3D[] PointsUpperDownLeft;
PointsUpperDownLeft = GetLinePoints(Points(0), Points(3));
Position3D[] PointsUpperDownRight;
PointsUpperDownRight = GetLinePoints(Points(1), Points(2));
long X;
long Y;
long R;
long G;
long B;
// Between the left and right vertical line points we get the horizontal line points:
Position3D[] DrawPixelPoints;
//UBound is the last array index:
for (Y = 0; (Y
<= (GetLastElementArray(PointsUpperDownLeft) - 1)); Y++) {
DrawPixelPoints = GetLinePoints(PointsUpperDownRight[Y], PointsUpperDownLeft[Y]);
for (X = 0; (X
<= (GetLastElementArray(DrawPixelPoints) - 1)); X++) {
POINTAPI Point;
long color;
long PosX;
long PosY;
PosX = X;
PosY = Y;
// Test the image size for we tiled the image:
if ((PosX > ImageWidth)) {
while ((PosX >= ImageWidth)) {
PosX = (PosX - ImageWidth);
}
if ((PosY >= ImageHeight)) {
while ((PosY > ImageHeight)) {
PosY = (PosY - ImageHeight);
}
// Get the pixel color(ARGB):
GdipBitmapGetPixel( hBitmap, PosX, PosY, color);
// Convert ARGB to RGB:
R =(color>> 16) & 0xff;
G=(color>> 8) & 0xff;
B = (color & 0xff);
if ((color == CLR_INVALID)) {
break;
}
// Convert the 3D point to 2D point:
Point = ConvertPositon3DTo2D(DrawPixelPoints[X], WorldSize);
// Draw the pixel on point:
//SetPixelV( DestinationHDC, Point.X, Point.Y, RGB(R, G, B));
GdipBitmapSetPixel (MemhBitmap, Point.X, Point.Y, color);
}
}
Point = ConvertPositon3DTo2D(PointsUpperDownLeft(0), WorldSize);
GdipDeleteGraphics (hGraphics);
GdipCreateFromHDC(DestinationHDC, hGraphics);
GdipDrawImage (DestinationHDC, MemhBitmap, Point.X, Point.Y);
}
| |