Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGS small update #2984

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
12 changes: 6 additions & 6 deletions source/Cosmos.Plugs/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@
"Cosmos.Debug.Kernel": "[0.1.0-localbuild, )",
"Cosmos.IL2CPU": "[0.1.0-localbuild, )",
"System.Reflection.TypeExtensions": "[4.7.0, )",
"XSharp": "[10.0.0, )"
"XSharp": "[0.1.0-localbuild, )"
}
},
"cosmos.core_plugs": {
Expand All @@ -1127,7 +1127,7 @@
"Cosmos.Core_Asm": "[0.1.0-localbuild, )",
"Cosmos.Debug.Kernel": "[0.1.0-localbuild, )",
"IgnoresAccessChecksToGenerator": "[0.5.0, )",
"XSharp": "[10.0.0, )"
"XSharp": "[0.1.0-localbuild, )"
}
},
"cosmos.debug.kernel": {
Expand All @@ -1138,7 +1138,7 @@
"dependencies": {
"Cosmos.Debug.Kernel": "[0.1.0-localbuild, )",
"IL2CPU.API": "[0.1.0-localbuild, )",
"XSharp": "[10.0.0, )"
"XSharp": "[0.1.0-localbuild, )"
}
},
"cosmos.hal2": {
Expand All @@ -1163,7 +1163,7 @@
"System.Reflection.TypeExtensions": "[4.7.0, )",
"System.Runtime.CompilerServices.Unsafe": "[5.0.0, )",
"System.Runtime.Loader": "[4.3.0, )",
"XSharp": "[10.0.0, )"
"XSharp": "[0.1.0-localbuild, )"
}
},
"cosmos.system2": {
Expand Down Expand Up @@ -1217,9 +1217,9 @@
"xsharp": {
"type": "Project",
"dependencies": {
"Spruce": "[10.0.0, )"
"Spruce": "[0.1.0-localbuild, )"
}
}
}
}
}
}
25 changes: 24 additions & 1 deletion source/Cosmos.System2/Graphics/Bitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,36 @@ private void CreateBitmap(Stream stream, ColorOrder colorOrder)
/// <returns>resized image</returns>
public static Bitmap Resize(Bitmap image, uint NewW, uint NewH)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename NewW to newWidth and NewH to newHeight

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not fixed

{

Bitmap tmp = new Bitmap(1,1,image.Depth);
tmp.RawData = image.RawData;
tmp.Resize(NewW,NewH);
return tmp;
}

/// <summary>
/// Gets a rectangle of pixels and stores it into a bitmap
/// </summary>
/// <param name="X">the x coordinate of the rectangle</param>
/// <param name="Y">the y coordinate of the rectangle</param>
/// <param name="W">the width of the rectangle</param>
/// <param name="H">the height of the rectangle</param>
/// <returns>bitmap</returns>
public static Bitmap FromCanvasRegion(Canvas canvas,int X, int Y, ushort W, ushort H)
Samma2009 marked this conversation as resolved.
Show resolved Hide resolved
Samma2009 marked this conversation as resolved.
Show resolved Hide resolved
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the additional new lines and tabbing of the function

Bitmap tmp = new Bitmap(W, H, canvas.Mode.ColorDepth);

Samma2009 marked this conversation as resolved.
Show resolved Hide resolved
for (int x = X; x < W + X; x++)
{
for (int y = Y; y < H + Y; y++)
{
tmp.SetPixel(canvas.GetPointColor(x, y), x - X, y - Y);
}
}

return tmp;

}

/// <summary>
/// Saves the given image as a BMP file.
Expand Down
27 changes: 1 addition & 26 deletions source/Cosmos.System2/Graphics/Canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -641,39 +641,14 @@ public void DrawImageAlpha(Image image, int x, int y)
for (int yi = 0; yi < image.Height; yi++)
{
color = Color.FromArgb(image.RawData[xi + (yi * image.Width)]);
if (color.A >0)
if (color.A > 0)
{
DrawPoint(color, x + xi, y + yi);
}
}
}
}

/// <summary>
/// Gets a rectangle of pixels and stores it into a bitmap
/// </summary>
/// <param name="X">the x coordinate of the rectangle</param>
/// <param name="Y">the y coordinate of the rectangle</param>
/// <param name="W">the width of the rectangle</param>
/// <param name="H">the height of the rectangle</param>
/// <returns>bitmap</returns>
public Bitmap GetPixels(int X,int Y,ushort W,ushort H)
{

Bitmap tmp = new Bitmap(W,H,this.Mode.ColorDepth);

for (int x = X; x < W + X; x++)
{
for (int y = Y; y < H + Y; y++)
{
tmp.SetPixel(GetPointColor(x,y),x - X,y - Y);
}
}

return tmp;

}

/// <summary>
/// Draws a string using the given bitmap font.
/// </summary>
Expand Down