Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 27 additions & 96 deletions src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DefineConstants>$(DefineConstants);DRAWING_NAMESPACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningsNotAsErrors>CS0618</WarningsNotAsErrors>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum)-Unix;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<AddXamarinPlaceholderFilesToPackage>true</AddXamarinPlaceholderFilesToPackage>
Expand All @@ -18,7 +18,7 @@ System.Drawing.Font
System.Drawing.Graphics
System.Drawing.Icon

Unix support is disabled by default. See https://aka.ms/systemdrawingnonwindows for more information.</PackageDescription>
Since .NET 7, non-Windows platforms are not supported, even with the runtime configuration switch. See https://aka.ms/systemdrawingnonwindows for more information.</PackageDescription>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
Expand Down Expand Up @@ -193,60 +193,34 @@ Unix support is disabled by default. See https://aka.ms/systemdrawingnonwindows
Link="Common\System\Text\ValueStringBuilder.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<EmbeddedResource Include="Resources\System\Drawing\DefaultComponent.bmp">
<LogicalName>System.Drawing.DefaultComponent.bmp</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\System\Drawing\Printing\PrintDocument.bmp" />
<EmbeddedResource Include="Resources\System\Drawing\ShieldIcon.ico">
<LogicalName>System.Drawing.ShieldIcon.ico</LogicalName>
</EmbeddedResource>
</ItemGroup>
<!-- Windows-specific -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
<Compile Include="SRDescriptionAttribute.cs" />
<Compile Include="System\Drawing\Bitmap.Windows.cs" />
<Compile Include="System\Drawing\BitmapSelector.cs" />
<Compile Include="System\Drawing\BufferedGraphics.Windows.cs" />
<Compile Include="System\Drawing\BufferedGraphicsContext.Windows.cs" />
<Compile Include="System\Drawing\BufferedGraphicsManager.Windows.cs" />
<Compile Include="System\Drawing\Drawing2D\CustomLineCap.Windows.cs" />
<Compile Include="System\Drawing\Drawing2D\GraphicsPath.Windows.cs" />
<Compile Include="System\Drawing\BufferedGraphicsManager.cs" />
<Compile Include="System\Drawing\Drawing2D\GraphicsPath.cs" />
<Compile Include="System\Drawing\DrawingCom.cs" />
<Compile Include="System\Drawing\Font.Windows.cs" />
<Compile Include="System\Drawing\FontFamily.Windows.cs" />
<Compile Include="System\Drawing\GdiplusNative.Windows.cs" />
<Compile Include="System\Drawing\Graphics.Windows.cs" />
<Compile Include="System\Drawing\DrawingCom.ComWrappers.cs" />
<Compile Include="System\Drawing\GraphicsContext.cs" />
<Compile Include="System\Drawing\Icon.Windows.cs" />
<Compile Include="System\Drawing\Image.Windows.cs" />
<Compile Include="System\Drawing\Imaging\BitmapData.Windows.cs" />
<Compile Include="System\Drawing\Imaging\Metafile.Windows.cs" />
<Compile Include="System\Drawing\Imaging\MetafileHeader.Windows.cs" />
<Compile Include="System\Drawing\Imaging\MetaHeader.Windows.cs" />
<Compile Include="System\Drawing\Icon.cs" />
<Compile Include="System\Drawing\Icon.ComWrappers.cs" />
<Compile Include="System\Drawing\Imaging\MetafileHeader.cs" />
<Compile Include="System\Drawing\Imaging\MetaHeader.cs" />
<Compile Include="System\Drawing\Internal\GpPathData.cs" />
<Compile Include="System\Drawing\Internal\GPStream.cs" />
<Compile Include="System\Drawing\Internal\GPStream.ComWrappers.cs" />
<Compile Include="System\Drawing\Internal\SystemColorTracker.cs" />
<Compile Include="System\Drawing\LocalAppContextSwitches.Windows.cs" />
<Compile Include="System\Drawing\Pen.Windows.cs" />
<Compile Include="System\Drawing\LocalAppContextSwitches.cs" />
<Compile Include="System\Drawing\Printing\DefaultPrintController.cs" />
<Compile Include="System\Drawing\Printing\ModeField.cs" />
<Compile Include="System\Drawing\Printing\PageSettings.Windows.cs" />
<Compile Include="System\Drawing\Printing\PreviewPrintController.Windows.cs" />
<Compile Include="System\Drawing\Printing\PrintController.Windows.cs" />
<Compile Include="System\Drawing\Printing\PrintDocument.Windows.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="System\Drawing\Printing\PrinterSettings.Windows.cs" />
<Compile Include="System\Drawing\Printing\PrintEventArgs.Windows.cs" />
<Compile Include="System\Drawing\Printing\PrintPageEventArgs.Windows.cs" />
<Compile Include="System\Drawing\Printing\PageSettings.cs" />
<Compile Include="System\Drawing\Printing\PrintDocument.cs" />
<Compile Include="System\Drawing\Printing\PrinterSettings.cs" />
<Compile Include="System\Drawing\Printing\PrintEventArgs.cs" />
<Compile Include="System\Drawing\Printing\PrintPageEventArgs.cs" />
<Compile Include="System\Drawing\Printing\PrintPreviewGraphics.cs" />
<Compile Include="System\Drawing\Printing\TriState.cs" />
<Compile Include="System\Drawing\Region.Windows.cs" />
<Compile Include="System\Drawing\ScreenDC.cs" />
<Compile Include="System\Drawing\SystemFonts.Windows.cs" />
<Compile Include="System\Drawing\SystemIcons.Windows.cs" />
<Compile Include="System\Drawing\SystemIcons.cs" />
<Compile Include="System\Drawing\ToolboxBitmapAttribute.cs" />
<Compile Include="System\Drawing\Text\PrivateFontCollection.Windows.cs" />
<Compile Include="misc\DbgUtil.cs" />
<Compile Include="misc\DpiHelper.cs" />
<Compile Include="misc\GDI\ApplyGraphicsProperties.cs" />
Expand Down Expand Up @@ -292,6 +266,8 @@ Unix support is disabled by default. See https://aka.ms/systemdrawingnonwindows
Link="Common\Interop\Windows\Gdi32\Interop.GetRgnBox.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetStockObject.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetStockObject.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Ole32\Interop.IStream.COMWrappers.cs"
Link="Common\Interop\Windows\Ole32\Interop.IStream.COMWrappers.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.ObjectType.cs"
Link="Common\Interop\Windows\Gdi32\Interop.ObjectType.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.OffsetViewportOrgEx.cs"
Expand Down Expand Up @@ -332,60 +308,15 @@ Unix support is disabled by default. See https://aka.ms/systemdrawingnonwindows
Link="Common\Interop\Windows\User32\Interop.WindowFromDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.HRESULT.cs"
Link="Common\Interop\Windows\Interop.HRESULT.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Ole32\Interop.IStream.COMWrappers.cs"
Link="Common\Interop\Windows\Ole32\Interop.IStream.COMWrappers.cs" />
<Compile Include="System\Drawing\DrawingCom.COMWrappers.cs" />
<Compile Include="System\Drawing\Icon.Windows.COMWrappers.cs" />
<Compile Include="System\Drawing\Internal\GPStream.COMWrappers.cs" />
</ItemGroup>
<!-- Unix specific -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'Unix'">
<Compile Include="System\Drawing\Graphics.Unix.cs" />
<Compile Include="System\Drawing\Icon.Unix.cs" />
<Compile Include="System\Drawing\SystemFonts.Unix.cs" />
<Compile Include="System\Drawing\Imaging\BitmapData.Unix.cs" />
<Compile Include="System\Drawing\Imaging\Metafile.Unix.cs" />
<Compile Include="System\Drawing\Imaging\MetafileHeader.Unix.cs" />
<Compile Include="System\Drawing\Imaging\MetaHeader.Unix.cs" />
<Compile Include="System\Drawing\Printing\LibcupsNative.cs" />
<Compile Include="System\Drawing\Printing\PrintingServices.Unix.cs" />
<Compile Include="System\Drawing\Printing\PageSettings.Unix.cs" />
<Compile Include="System\Drawing\Printing\PreviewPrintController.Unix.cs" />
<Compile Include="System\Drawing\Printing\PrintController.Unix.cs" />
<Compile Include="System\Drawing\Printing\PrintDocument.Unix.cs" />
<Compile Include="System\Drawing\Printing\PrinterSettings.Unix.cs" />
<Compile Include="System\Drawing\Printing\PrintEventArgs.Unix.cs" />
<Compile Include="System\Drawing\Printing\PrintPageEventArgs.Unix.cs" />
<Compile Include="System\Drawing\Printing\StandardPrintController.Unix.cs" />
<Compile Include="System\Drawing\Bitmap.Unix.cs" />
<Compile Include="System\Drawing\BufferedGraphics.Unix.cs" />
<Compile Include="System\Drawing\BufferedGraphicsManager.Unix.cs" />
<Compile Include="System\Drawing\BufferedGraphicsContext.Unix.cs" />
<Compile Include="System\Drawing\macFunctions.cs" />
<Compile Include="System\Drawing\Font.Unix.cs" />
<Compile Include="System\Drawing\FontFamily.Unix.cs" />
<Compile Include="System\Drawing\GdiplusNative.Unix.cs" />
<Compile Include="System\Drawing\GdiPlusStreamHelper.Unix.cs" />
<Compile Include="System\Drawing\LibX11Functions.cs" />
<Compile Include="System\Drawing\LocalAppContextSwitches.Unix.cs" />
<Compile Include="System\Drawing\MarshallingHelpers.cs" />
<Compile Include="System\Drawing\Image.Unix.cs" />
<Compile Include="System\Drawing\Pen.Unix.cs" />
<Compile Include="System\Drawing\Region.Unix.cs" />
<Compile Include="System\Drawing\SRDescriptionAttribute.cs" />
<Compile Include="System\Drawing\SystemIcons.Unix.cs" />
<Compile Include="System\Drawing\ToolboxBitmapAttribute.Unix.cs" />
<Compile Include="System\Drawing\Drawing2D\AdjustableArrowCap.Unix.cs" />
<Compile Include="System\Drawing\Drawing2D\CustomLineCap.Unix.cs" />
<Compile Include="System\Drawing\Drawing2D\GraphicsPath.Unix.cs" />
<Compile Include="System\Drawing\Text\PrivateFontCollection.Unix.cs" />
<Compile Include="System\Drawing\LibraryResolver.cs" />
<Compile Include="Interop\Unix\Interop.Libraries.cs" />
<EmbeddedResource Include="Resources\System\Drawing\Error.ico">
<LogicalName>placeholder.ico</LogicalName>
<EmbeddedResource Include="Resources\System\Drawing\DefaultComponent.bmp">
<LogicalName>System.Drawing.DefaultComponent.bmp</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\System\Drawing\Printing\PrintDocument.bmp" />
<EmbeddedResource Include="Resources\System\Drawing\ShieldIcon.ico">
<LogicalName>System.Drawing.ShieldIcon.ico</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) and '$(TargetPlatformIdentifier)' != ''">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) and '$(TargetsAnyOS)' != 'true'">
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs"
Link="Common\DisableRuntimeMarshalling.cs" />
<Compile Include="$(CommonPath)System\Runtime\InteropServices\HandleRefMarshaller.cs"
Expand Down

This file was deleted.

This file was deleted.

23 changes: 22 additions & 1 deletion src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.ComponentModel;
using System.Drawing.Imaging;
using System.Drawing.Internal;
using System.IO;
using System.Runtime.InteropServices;
using Gdip = System.Drawing.SafeNativeMethods.Gdip;
Expand All @@ -14,7 +15,7 @@ namespace System.Drawing
"System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed partial class Bitmap : Image
public sealed class Bitmap : Image
{
private static readonly Color s_defaultTransparentColor = Color.LightGray;

Expand Down Expand Up @@ -53,6 +54,26 @@ public Bitmap(Stream stream) : this(stream, false)
{
}

public unsafe Bitmap(Stream stream!!, bool useIcm)
{
using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));

IntPtr bitmap = IntPtr.Zero;
if (useIcm)
{
Gdip.CheckStatus(Gdip.GdipCreateBitmapFromStreamICM(streamWrapper.Ptr, &bitmap));
}
else
{
Gdip.CheckStatus(Gdip.GdipCreateBitmapFromStream(streamWrapper.Ptr, &bitmap));
}

ValidateImage(bitmap);

SetNativeImage(bitmap);
EnsureSave(this, null, stream);
}

public Bitmap(Type type, string resource) : this(GetResourceStream(type, resource))
{
}
Expand Down
Loading