Closed fanoI closed 6 years ago
check out cjhannah's image class
Probably DrawImage is a thing that should be done at a higher level or in intermediate "library" or directly on the tool kit itself, I'm unsure if it would really part of CGS. If @cjhannah wants to help to port his image class to CGS will be wonderful.
Why the variable 'color'? An image can be seen as an array of colored pixels so it is not needed... or are you thinking of a border color? This should be done at higher level (in the widget toolkit) in the "PictureBox" object.
The method prototype was only an example in any case.
@fanoI there is no fill for the rectangles that i can see just a border
also no way to find the edge of the canvas to fit to the edge of the screen
DrawFilledRectangle() is one of the methods that should be implemented as you can see here: https://github.com/CosmosOS/Cosmos/issues/603
if you want you could start from here.
I would say just implement the functions as the System.Drawing.Graphics class is so you have portability and if you want to add border then create a library for people.
Yes I think having a sort of compatibility / familiarity with the .Net System.Drawing is good! Indeed my idea is to use the same prototype of the .Net class.
I think that System.Drawing in .NET Core only has primitive types (Color, Point,...).
They are in the process of porting the Mono version of System.Drawing (so to have something working on "Unix" too) and I think they will port DrawImage too: https://github.com/dotnet/corefx/issues/20712
To be clear for me DrawImage() means a simple bitmap not a GIF / JPEG / PNG the image conversion to BMP shall be done by an high level library.
If not what is your idea? In the end draw a bitmap is not simply a for() of DrawPoint() or I make it too simple?
We can plug System.Drawing as a graphics library, then it would call the draw methods to draw images and text. I think that there's no need to have a DrawImage method in Canvas, as no graphics driver will have a specific implementation for it.
The motive because I have not plugged directly System.Graphics was because to for example do a DrawRectangle() you needed a Winform but now in CoreFx they have said that instead System.Drawing is the building block of Winform... I'm a little confused now.
Graphics aren't a priority for now, so let's keep things simple. When we move to .NET Core 2.0, we can decide better what to do.
I concord better to wait Net Core 2.0 / Net Standard and see what they decide to do with System.Drawing obviously we can / should participate in the process so that it could be usable by us too.
Taking again inspiration from System.Drawing.Graphics the method should be this: public void DrawImage(Image image, int x, int y)
Image is an abstract class from which BitMap and MetaFile (?) inherit the primary objective of this issue would to load a simple 32 bit bitmap file from disk and show it on screen so if plugs are needed try to limit to this.
System.Drawing.Graphics has another overload of this method: public void DrawImage(Image image, int x, int y, int width, int height)
this is not be needed in CGS probably resizing could be done better at higher level (in the Widget ToolKit or in a user application).