PremultiplyComponents
TiffImage.PremultiplyComponents property
الحصول على أو تعيين قيمة تشير إلى ما إذا كان يجب مضاعفة المكونات مسبقًا.
public override bool PremultiplyComponents { get; set; }
Property_Value
حقيقي
إذا كان يجب مضاعفة المكونات مسبقًا ؛ خلاف ذلك،خاطئة
.
أمثلة
يُنشئ المثال التالي صورة TIFF جديدة ، ويحفظ وحدات البكسل شبه الشفافة المحددة ، ثم يقوم بتحميل تلك البيكسلات ويحصل على الألوان النهائية في شكل ما قبل المضاعفة.
[C#]
int imageWidth = 3;
int imageHeight = 2;
Aspose.Imaging.Color[] colors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.FromArgb(127, 255, 0, 0),
Aspose.Imaging.Color.FromArgb(127, 0, 255, 0),
Aspose.Imaging.Color.FromArgb(127, 0, 0, 255),
Aspose.Imaging.Color.FromArgb(127, 255, 255, 0),
Aspose.Imaging.Color.FromArgb(127, 255, 0, 255),
Aspose.Imaging.Color.FromArgb(127, 0, 255, 255),
};
Aspose.Imaging.ImageOptions.TiffOptions createOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffDeflateRgba);
createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Create(createOptions, imageWidth, imageHeight))
{
// حفظ بكسل للصورة بأكملها.
image.SavePixels(image.Bounds, colors);
// يتم تخزين البكسل في الصورة الأصلية في شكل غير مسبوق المضاعفة.
// تحتاج إلى تحديد الخيار المقابل بشكل صريح للحصول على مكونات اللون المضاعفة مسبقًا.
// يتم حساب مكونات اللون المضاعفة مسبقًا بواسطة الصيغ:
// أحمر = original_red * alpha / 255 ;
// أخضر = original_green * alpha / 255 ;
// blue = original_blue * alpha / 255 ;
image.PremultiplyComponents = true;
Aspose.Imaging.Color[] premultipliedColors = image.LoadPixels(image.Bounds);
for (int i = 0; i < colors.Length; i++)
{
System.Console.WriteLine("Original color: {0}", colors[i].ToString());
System.Console.WriteLine("Premultiplied color: {0}", premultipliedColors[i].ToString());
}
}
// سيبدو الناتج كالتالي:
// اللون الأصلي: اللون [A = 127 ، R = 255 ، G = 0 ، B = 0]
// لون سابق المضاعفة: اللون [A = 127 ، R = 127 ، G = 0 ، B = 0]
// اللون الأصلي: اللون [A = 127 ، R = 0 ، G = 255 ، B = 0]
// لون سابق المضاعفة: اللون [A = 127 ، R = 0 ، G = 127 ، B = 0]
// اللون الأصلي: اللون [A = 127 ، R = 0 ، G = 0 ، B = 255]
// لون سابق المضاعفة: اللون [A = 127 ، R = 0 ، G = 0 ، B = 127]
// اللون الأصلي: اللون [A = 127 ، R = 255 ، G = 255 ، B = 0]
// لون سابق المضاعفة: اللون [A = 127 ، R = 127 ، G = 127 ، B = 0]
// اللون الأصلي: اللون [A = 127 ، R = 255 ، G = 0 ، B = 255]
// لون سابق المضاعفة: اللون [A = 127 ، R = 127 ، G = 0 ، B = 127]
// اللون الأصلي: اللون [A = 127 ، R = 0 ، G = 255 ، B = 255]
// لون سابق المضاعفة: اللون [A = 127 ، R = 0 ، G = 127 ، B = 127]
أنظر أيضا
- class TiffImage
- مساحة الاسم Aspose.Imaging.FileFormats.Tiff
- المجسم Aspose.Imaging