Explorar el Código

* GraphicsPath.jvm.cs: fixed FillMode, ConvertArcAngle, AddPath, CloseFigure
* Bitmap.jvm.cs: fixed InternalSave, ToBufferedImageFormat, Clone
* PlainImage.jvm.cs: fixed Clone
* Graphics.jvm.cs: fixed FillShape, Clear, FillScaledShape

svn path=/trunk/mcs/; revision=51918

Vladimir Krasnov hace 20 años
padre
commit
7ff4e4574e

+ 5 - 0
mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog

@@ -1,3 +1,8 @@
+2005-10-19 Vladimir Krasnov <[email protected]>
+
+	* GraphicsPath.jvm.cs: fixed FillMode, ConvertArcAngle, AddPath,
+	CloseFigure
+	
 2005-10-19 Vladimir Krasnov <[email protected]>
 
 	* LinearGradientBrush.jvm.cs: fixed clone(), SetBlendTriangularShape, 

+ 11 - 8
mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.jvm.cs

@@ -103,7 +103,7 @@ namespace System.Drawing.Drawing2D
 		public FillMode FillMode 
 		{
 			get 
-			{   if(NativeObject.getWindingRule() == GeneralPath.WIND_NON_ZERO)
+			{   if(NativeObject.getWindingRule() == GeneralPath.WIND_EVEN_ODD)
 					return FillMode.Alternate;
 				else
 					return FillMode.Winding;
@@ -112,9 +112,9 @@ namespace System.Drawing.Drawing2D
 			set 
 			{
 				if (value == FillMode.Alternate)
-					NativeObject.setWindingRule (GeneralPath.WIND_NON_ZERO);
-				else
 					NativeObject.setWindingRule (GeneralPath.WIND_EVEN_ODD);
+				else
+					NativeObject.setWindingRule (GeneralPath.WIND_NON_ZERO);
 			}
 		}
 
@@ -203,7 +203,7 @@ namespace System.Drawing.Drawing2D
 			double cosx = 1/Math.Sqrt( sqrd1Tod2 * (tan*tan) + 1);
 			double xRad = Math.Acos(cosx);
 			double x = java.lang.Math.toDegrees(xRad);
-			int q = ((int)angle)/90;
+			int q = (Math.Abs((int)angle))/90;
 
 			switch (q&3) {
 				case 1:
@@ -466,6 +466,9 @@ namespace System.Drawing.Drawing2D
 		#region AddPath
 		public void AddPath (GraphicsPath addingPath, bool connect)
 		{
+			if (NativeObject.LastFigureClosed || addingPath.NativeObject.LastFigureClosed)
+				connect = false;
+
 			NativeObject.append(addingPath.NativeObject,connect);
 		}
 		#endregion
@@ -846,10 +849,10 @@ namespace System.Drawing.Drawing2D
 			Shape = p;
 		}  	
                 
-		public void CloseFigure()
-		{
-			NativeObject.closePath();
-		} 
+		public void CloseFigure() {
+			if (!NativeObject.LastFigureClosed)
+				NativeObject.closePath();
+		}
 		#endregion
 
 		#region Flatten

+ 14 - 8
mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs

@@ -149,6 +149,13 @@ namespace System.Drawing
 			if (ic != null) {
 				ic.NativeStream = output;
 				ic.WritePlainImage( CurrentImage );
+				
+				try {
+					output.close();
+				}
+				catch (java.io.IOException ex) {
+					throw new System.IO.IOException(ex.Message, ex);
+				}
 			}
 			else {
 				throw new NotSupportedException("The requested format encoder is not supported");
@@ -178,7 +185,7 @@ namespace System.Drawing
 				case PixelFormat.Indexed:
 					return BufferedImage.TYPE_BYTE_INDEXED;
 				default:
-					return 0;
+					return BufferedImage.TYPE_INT_ARGB;
 			}			
 		}
 
@@ -222,13 +229,12 @@ namespace System.Drawing
 		
 		public Bitmap Clone (RectangleF rect, PixelFormat pixFormat)
 		{
-			PlainImage plainImage = (PlainImage)CurrentImage.Clone();
-			plainImage.NativeImage = ((BufferedImage)plainImage.NativeImage).getSubimage((int)rect.X,(int)rect.Y,(int)rect.Width,(int)rect.Height);
-			
-			if (pixFormat != this.PixelFormat)
-				throw new NotImplementedException ("Converting PixelFormat is not implemented yet.");
-	
-			return new Bitmap(plainImage);
+			PlainImage plainImage = CurrentImage.Clone(false);
+			BufferedImage clone = new BufferedImage( (int)rect.Width, (int)rect.Height, ToBufferedImageFormat( pixFormat ) );
+			clone.getGraphics().drawImage( NativeObject, -(int)rect.X, -(int)rect.Y, null );
+
+			plainImage.NativeImage = clone;
+			return new Bitmap(plainImage);
 		}
 		#endregion
 

+ 6 - 0
mcs/class/System.Drawing/System.Drawing/ChangeLog

@@ -1,3 +1,9 @@
+2005-10-19 Vladimir Krasnov <[email protected]>
+
+	* Bitmap.jvm.cs: fixed InternalSave, ToBufferedImageFormat, Clone
+	* PlainImage.jvm.cs: fixed Clone
+	* Graphics.jvm.cs: fixed FillShape, Clear, FillScaledShape
+
 2005-10-19 Vladimir Krasnov <[email protected]>
 
 	* Brush.jvm.cs: added InternalClone() method

+ 21 - 7
mcs/class/System.Drawing/System.Drawing/Graphics.jvm.cs

@@ -369,7 +369,7 @@ namespace System.Drawing {
 				}
 			}
 		}
-		void FillShape(awt.Paint paint, awt.Shape shape) {
+		void FillShape(Brush paint, awt.Shape shape) {
 			if (paint == null)
 				throw new ArgumentNullException("brush");
 
@@ -419,16 +419,30 @@ namespace System.Drawing {
 			return path;
 		}
 
-		void FillScaledShape(awt.Paint paint, awt.Shape shape, geom.Area clip) {
+		void FillScaledShape(Brush paint, awt.Shape shape, geom.Area clip) {
 			geom.Rectangle2D r = shape.getBounds2D();
 			awt.Paint oldP = NativeObject.getPaint();
-			NativeObject.setPaint(paint);
+
+
+			Matrix m = null;
+			if (!_transform.IsIdentity) {
+				m = paint.BrushTransform;
+				paint.BrushMultiplyTransform( _transform );
+			}
+
 			try {
-				shape = IntersectUserClip(shape, clip);
-				NativeObject.fill(shape);
+				NativeObject.setPaint(paint);
+				try {
+					shape = IntersectUserClip(shape, clip);
+					NativeObject.fill(shape);
+				}
+				finally {
+					NativeObject.setPaint(oldP);
+				}
 			}
 			finally {
-				NativeObject.setPaint(oldP);
+				if (m != null)
+					paint.BrushTransform = m;
 			}
 		}
 
@@ -620,7 +634,7 @@ namespace System.Drawing {
 		
 		#region Clear
 		public void Clear (Color color) {
-			FillScaledShape(color.NativeObject, _clip.NativeObject, null);
+			FillScaledShape(new SolidBrush( color ), _clip.NativeObject, null);
 		}
 		#endregion
 

+ 21 - 14
mcs/class/System.Drawing/System.Drawing/PlainImage.jvm.cs

@@ -99,20 +99,27 @@ namespace Mainsoft.Drawing.Imaging
 		#region ICloneable members
 
 		public object Clone() {
-			
-			awt.Image img = new BufferedImage(
-				((BufferedImage)NativeObject).getColorModel(), 
-				((BufferedImage)NativeObject).copyData(null), 
-				((BufferedImage)NativeObject).isAlphaPremultiplied(), null);
-
-			awt.Image [] th = null;
-			if (Thumbnails != null) {
-				th = new java.awt.Image[ Thumbnails.Length ];
-				for (int i=0; i < Thumbnails.Length; i++) {
-					th[i] = new BufferedImage(
-						((BufferedImage)Thumbnails[i]).getColorModel(), 
-						((BufferedImage)Thumbnails[i]).copyData(null), 
-						((BufferedImage)Thumbnails[i]).isAlphaPremultiplied(), null);
+			return Clone(true);
+		}
+
+		public PlainImage Clone(bool cloneImage) {
+			awt.Image img = NativeImage;
+			awt.Image [] th = _thumbnails;
+
+			if (cloneImage) {
+				img = new BufferedImage(
+					((BufferedImage)NativeObject).getColorModel(), 
+					((BufferedImage)NativeObject).copyData(null), 
+					((BufferedImage)NativeObject).isAlphaPremultiplied(), null);
+
+				if (Thumbnails != null) {
+					th = new java.awt.Image[ Thumbnails.Length ];
+					for (int i=0; i < Thumbnails.Length; i++) {
+						th[i] = new BufferedImage(
+							((BufferedImage)Thumbnails[i]).getColorModel(), 
+							((BufferedImage)Thumbnails[i]).copyData(null), 
+							((BufferedImage)Thumbnails[i]).isAlphaPremultiplied(), null);
+					}
 				}
 			}