Rank: Member
Groups: Guest
Joined: 2/15/2007(UTC) Posts: 18
|
Hi There, We have been using Graphics Mill for a proof of concept. Our problem is that we need to combine 4 trapezoidal images together as one i.e. as a box/frame when you piece them together. To do this, we have first constructed the rectangles and are then using the Combiner class and applying a mask to get the trapeziums required. Sample code for this is below: method is passed the Bitmap called 'side' and then: Code:Aurigma.GraphicsMill.Bitmap mask = side.GetEmptyMask();
Aurigma.GraphicsMill.Drawing.GdiGraphics g = mask.GetGdiGraphics();
Aurigma.GraphicsMill.Drawing.SolidBrush brush = new Aurigma.GraphicsMill.Drawing.SolidBrush();
brush.Color = Aurigma.GraphicsMill.RgbColor.White;
System.Drawing.Point[] points = {
new System.Drawing.Point(0, 0),
new System.Drawing.Point(side.Width, 0),
new System.Drawing.Point(side.Width - side.Height, side.Height),
new System.Drawing.Point(side.Height, side.Height)
};
g.FillPolygon(brush, points);
Aurigma.GraphicsMill.Transforms.Combiner c = new Aurigma.GraphicsMill.Transforms.Combiner();
Aurigma.GraphicsMill.Bitmap maskResult = new Aurigma.GraphicsMill.Bitmap(side.Width, side.Height, side.PixelFormat);
c.CombineMode = Aurigma.GraphicsMill.Transforms.CombineMode.Alpha;
c.SourceBitmap = side;
c.ApplyMaskTransform(maskResult, mask);
return maskResult;
This seems to be working correctly for us, which is great - from this we can generate 4 trapezium shapes i.e. rectangles with 2 trianglar pieces sliced off. Or so it seems - the images which are produced have a trapezoidal shape of the image we require and then two black triangles (which we believe are transparent). The problem is that then, we need to combine the 4 sides and we do this by using the following code similar to the following: method is passed bitmaps topSide, leftSide, rightSide and bottomSide and then... Code:Aurigma.GraphicsMill.Bitmap final = new Aurigma.GraphicsMill.Bitmap(workingBitmap);
final = drawBitmapOnBitmap(topSide, final, 0, 0);
final = drawBitmapOnBitmap(leftSide, final , 0, 0);
final = drawBitmapOnBitmap(rightSide, final , topSide.Width - rightSide.Width, 0);
final = drawBitmapOnBitmap(bottomSide, final , 0, leftSide.Height - bottomSide.Height);
where draw bitmap effectively does the following: sourceBitmap.Draw(destinationBitmap, destinationX, destinationY, sourceBitmap.Width, sourceBitmap.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, 1.0f, Aurigma.GraphicsMill.Transforms.InterpolationMode.LowQuality);[/code] This works fine except for the fact that on the combined image, the black from the trapezium images shows up AS BLACK. i.e. it covers other parts of images whic it should be letting show through. We were expecting to black to be transparent when combined in this way but it is not - it's solid black. Are we missing something here.. or is the whole approach (i.e. using Combine with Mask and then combining with Draw) wrong to begin with? Many Thanks in Advance for your help! Edited by user Tuesday, December 18, 2007 5:02:38 PM(UTC)
| Reason: Not specified
|