]> O.S.I.I.S - jp/crow.git/commitdiff
optional use of CrowStbSharp instead of native lib, ide wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 24 Feb 2020 15:25:26 +0000 (16:25 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 9 May 2020 22:50:02 +0000 (00:50 +0200)
Crow/Crow.csproj
Crow/src/Fill/BmpPicture.cs
Directory.Build.props
Samples/ShowCase/ShowCase.csproj
Samples/common/ui/Interfaces/Divers/0.crow

index 521683f36d5ef014d02ae26debbfc1cc0ed3681d..e34fcd64be0d1851934b6870195c8a9e3db66a6d 100644 (file)
@@ -5,16 +5,13 @@
                
                <ReleaseVersion>0.8.0</ReleaseVersion>
                <AssemblyVersion>$(CrowVersion)</AssemblyVersion>
-               
                <Title>C# Rapid Open Widget Toolkit</Title>
                <Description>C.R.O.W. is a widget toolkit and rendering engine developed in C# with templates, styles, compositing, and bindings.</Description>
                <License>MIT</License>
                <Authors>Jean-Philippe Bruyère</Authors>
                <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
-               
                <PackageVersion>$(CrowPackageVersion)</PackageVersion>
                <PackageTags>GUI Widget toolkit Interface C# .Net Mono</PackageTags>
-               
                <PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
                <PackageProjectUrl>https://github.com/jpbruyere/Crow/wiki</PackageProjectUrl>
                <PackageLicense>https://opensource.org/licenses/MIT</PackageLicense>
                        This release should solve most of ms dotnet exception, the win32 backend is
                        still untested. Next beta will have a glfw backend.
                </PackageReleaseNotes>
-               
                <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-               
                <GenerateDocumentationFile>true</GenerateDocumentationFile>
                <NoWarn>$(NoWarn);1591;1587;1570;1572;1573;1574</NoWarn>
-               
+               <DefineConstants>DESIGN_MODE</DefineConstants>
                <DefineConstants>DESIGN_MODE</DefineConstants>
                <EnableDefaultItems>false</EnableDefaultItems>
                <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
                <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.6.0" />
                <!--<PackageReference Include="glfw-sharp" Version="0.2.0" />-->
        </ItemGroup>
+       <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
+               <DefineConstants>$(DefineConstants);STB_SHARP</DefineConstants>
+       </PropertyGroup>
+       <ItemGroup Condition=" '$(CrowStbSharp)' == 'true'">
+               <PackageReference Include="StbImageSharp" Version="2.22.4" />
+       </ItemGroup>
        <ItemGroup>
                <Content Include="$(SolutionDir)Images/crow.png" Pack="true" PackagePath="" />
                <Compile Include="src\**\*.cs" Exclude="src\Mono.Cairo\NativeMethods-internal.cs;src\backends\win32\User32\Structs\RawInputDevice.cs" />
index a67f66f1a912fb16efbc6db33171831ad14352ca..b707326eaff8dc909d1a7041e810418c6680a9ec 100644 (file)
@@ -1,28 +1,6 @@
-//
-// BmpPicture.cs
+// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// 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
 
                /// <summary>
                /// paint the image in the rectangle given in arguments according
index 34cb5efa78e49bb21e4096c4c9457cb31fa15d81..66bf81326e9daf3ee849ee30803e9495727301c7 100644 (file)
@@ -9,5 +9,6 @@
                
                <CrowVersion>0.8.8</CrowVersion>
                <CrowPackageVersion>$(CrowVersion)-beta</CrowPackageVersion>
+        <CrowStbSharp>true</CrowStbSharp>
        </PropertyGroup>
 </Project>
index 2de51a504a462363486efe85e6eb9211f1240418..9d79116420d34d23c6300b05c262002564360753 100644 (file)
                        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
                        <Link>Interfaces\%(RecursiveDir)%(Filename)%(Extension)</Link>
                </None>
+               <None Include="$(SolutionDir)\Images\**\*.*">
+                       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+                       <Link>Images\%(RecursiveDir)%(Filename)%(Extension)</Link>
+               </None>
        </ItemGroup>
        <ItemGroup>
                <None Remove="..\common\ui\Interfaces\basicTests\7.crow" />
index 4b6c50fbf141f3ff36256b3bfc0230be0e0c2a87..8850e26dc6f429d6aaca0b3fb9e76c924b195c32 100644 (file)
@@ -89,7 +89,9 @@
                        <Expandable>
                                <Image Path="#Crow.Icons.crow.svg" />
                        </Expandable>
-                       <Popper />
+                       <Popper >
+                               <Image Path="#Crow.Icons.crow.svg" Background="White" Height="100" Width="100" Margin="20" />
+                       </Popper>
                        <Slider Height="10" Width="90%" />
                        <Container Height="Fit" Width="200" Background="DimGrey" Margin="2" CornerRadius="5">
                                <ProgressBar Background="DimGrey" Height="10" Value="50" />