From: Jean-Philippe Bruyère Date: Mon, 24 Feb 2020 15:25:26 +0000 (+0100) Subject: optional use of CrowStbSharp instead of native lib, ide wip X-Git-Tag: v0.9.5-beta~127 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=33fda3d0638abcf75a5b6e20918658982cac425a;p=jp%2Fcrow.git optional use of CrowStbSharp instead of native lib, ide wip --- diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 521683f3..e34fcd64 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -5,16 +5,13 @@ 0.8.0 $(CrowVersion) - C# Rapid Open Widget Toolkit C.R.O.W. is a widget toolkit and rendering engine developed in C# with templates, styles, compositing, and bindings. MIT Jean-Philippe Bruyère https://github.com/jpbruyere/Crow - $(CrowPackageVersion) GUI Widget toolkit Interface C# .Net Mono - False https://github.com/jpbruyere/Crow/wiki https://opensource.org/licenses/MIT @@ -24,12 +21,10 @@ This release should solve most of ms dotnet exception, the win32 backend is still untested. Next beta will have a glfw backend. - True - true $(NoWarn);1591;1587;1570;1572;1573;1574 - + DESIGN_MODE DESIGN_MODE false false @@ -44,6 +39,12 @@ + + $(DefineConstants);STB_SHARP + + + + diff --git a/Crow/src/Fill/BmpPicture.cs b/Crow/src/Fill/BmpPicture.cs index a67f66f1..b707326e 100644 --- a/Crow/src/Fill/BmpPicture.cs +++ b/Crow/src/Fill/BmpPicture.cs @@ -1,28 +1,6 @@ -// -// BmpPicture.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.IO; @@ -67,6 +45,18 @@ namespace Crow return; } using (Stream stream = Interface.StaticGetStreamFromPath (Path)) { +#if STB_SHARP + StbImageSharp.ImageResult stbi = StbImageSharp.ImageResult.FromStream (stream, StbImageSharp.ColorComponents.RedGreenBlueAlpha); + image = new byte [stbi.Data.Length]; + //rgba to argb for cairo. + for (int i = 0; i < stbi.Data.Length; i += 4) { + image [i] = stbi.Data[i + 2]; + image [i + 1] = stbi.Data [i + 1]; + image [i + 2] = stbi.Data [i]; + image [i + 3] = stbi.Data [i + 3]; + } + Dimensions = new Size (stbi.Width, stbi.Height); +#else using (StbImage stbi = new StbImage (stream)) { image = new byte [stbi.Size]; //rgba to argb for cairo. @@ -78,6 +68,7 @@ namespace Crow } Dimensions = new Size (stbi.Width, stbi.Height); } +#endif //loadBitmap (new System.Drawing.Bitmap (stream)); } @@ -107,7 +98,7 @@ namespace Crow bitmap.UnlockBits (data); }*/ - #region implemented abstract members of Fill +#region implemented abstract members of Fill public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) { @@ -141,7 +132,7 @@ namespace Crow ctx.SetSource (tmp); } } - #endregion +#endregion /// /// paint the image in the rectangle given in arguments according diff --git a/Directory.Build.props b/Directory.Build.props index 34cb5efa..66bf8132 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,5 +9,6 @@ 0.8.8 $(CrowVersion)-beta + true diff --git a/Samples/ShowCase/ShowCase.csproj b/Samples/ShowCase/ShowCase.csproj index 2de51a50..9d791164 100644 --- a/Samples/ShowCase/ShowCase.csproj +++ b/Samples/ShowCase/ShowCase.csproj @@ -26,6 +26,10 @@ PreserveNewest Interfaces\%(RecursiveDir)%(Filename)%(Extension) + + PreserveNewest + Images\%(RecursiveDir)%(Filename)%(Extension) + diff --git a/Samples/common/ui/Interfaces/Divers/0.crow b/Samples/common/ui/Interfaces/Divers/0.crow index 4b6c50fb..8850e26d 100644 --- a/Samples/common/ui/Interfaces/Divers/0.crow +++ b/Samples/common/ui/Interfaces/Divers/0.crow @@ -89,7 +89,9 @@ - + + +