

【转】[PPTX解析] 图片 重新着色存储详解
source link: https://lindexi.gitee.io/post/%E8%BD%AC-PPTX%E8%A7%A3%E6%9E%90-%E5%9B%BE%E7%89%87-%E9%87%8D%E6%96%B0%E7%9D%80%E8%89%B2%E5%AD%98%E5%82%A8%E8%AF%A6%E8%A7%A3.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

图像处理矩阵
在讲解如何解析PPTX图像存储前,我们先来说明一下如何处理图片,将其按照我们的想法和输入数据将其进行转换。
在图像处理中,我们通常使用矩阵来进行图像的像素处理,下面是一些常见的C#图像处理矩阵:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace ImageProcessService
{
/// <summary>
/// 颜色转换矩阵
/// </summary>
public static class ColorMatrices
{
/// <summary>
/// 使用给定的数量创建亮度过滤器矩阵。
/// <para>
/// 使用算法<see href="https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc"/>
/// </para>
/// </summary>
/// <remarks>
/// 值为 0 将创建一个完全黑色的图像。值为 1 时输入保持不变。
/// 其他值是效果的线性乘数。允许超过 1 的值,从而提供更明亮的结果。
/// </remarks>
/// <param name="amount">转化比例,必须大于或等于 0。</param>
/// <returns>The <see cref="ColorMatrix"/>.</returns>
public static ColorMatrix CreateBrightnessMatrix(float amount)
{
if (amount < 0)
{
throw new ArgumentOutOfRangeException(nameof(amount), "Threshold must be >= 0");
}
return new ColorMatrix
{
Matrix00 = amount,
Matrix11 = amount,
Matrix22 = amount,
Matrix33 = 1F
};
}
/// <summary>
/// 使用给定的数量创建灰度滤波器矩阵。
/// <para>
/// 使用算法<see href="https://en.wikipedia.org/wiki/Luma_%28video%29#Rec._601_luma_versus_Rec._709_luma_coefficients"/>
/// </para>
/// </summary>
/// <param name="amount">转化比例,必须大于或等于 0。</param>
/// <returns>The <see cref="ColorMatrix"/>.</returns>
public static ColorMatrix CreateGrayScaleMatrix(float amount)
{
if (amount < 0 || amount > 1)
{
throw new ArgumentOutOfRangeException(
nameof(amount),
"Threshold must be in range 0..1");
}
amount = 1F - amount;
var matrix = new ColorMatrix();
matrix.Matrix00 = .299F + (.701F * amount);
matrix.Matrix10 = .587F - (.587F * amount);
matrix.Matrix20 = 1F - (matrix.Matrix00 + matrix.Matrix10);
matrix.Matrix01 = .299F - (.299F * amount);
matrix.Matrix11 = .587F + (.2848F * amount);
matrix.Matrix21 = 1F - (matrix.Matrix01 + matrix.Matrix11);
matrix.Matrix02 = .299F - (.299F * amount);
matrix.Matrix12 = .587F - (.587F * amount);
matrix.Matrix22 = 1F - (matrix.Matrix02 + matrix.Matrix12);
matrix.Matrix33 = 1F;
return matrix;
}
/// <summary>
/// 使用给定的数量创建对比度过滤器矩阵。
/// <para>
/// 使用算法<see href="https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc"/>
/// </para>
/// </summary>
/// <remarks>
/// 值为 0 将创建一个完全灰色的图像。值为 1 时输入保持不变。
/// 其他值是效果的线性乘数。允许超过 1 的值,从而提供具有更高对比度的结果。
/// </remarks>
/// <param name="amount">转化比例,必须大于或等于 0。</param>
/// <returns>The <see cref="ColorMatrix"/>.</returns>
public static ColorMatrix CreateContrastMatrix(float amount)
{
if (amount < 0)
{
throw new ArgumentOutOfRangeException(nameof(amount), "Threshold must be >= 0");
}
var contrast = (-.5F * amount) + .5F;
return new ColorMatrix
{
Matrix00 = amount,
Matrix11 = amount,
Matrix22 = amount,
Matrix33 = 1F,
Matrix40 = contrast,
Matrix41 = contrast,
Matrix42 = contrast
};
}
/// <summary>
/// 使用给定的数量创建饱和度过滤器矩阵。
/// <para>
/// 使用算法<see href="https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc"/>
/// </para>
/// </summary>
/// <remarks>
/// 0 值是完全不饱和的。值为 1 时输入保持不变。
/// 其他值是效果的线性乘数。允许超过 1 的值,提供超饱和结果。
/// </remarks>
/// <param name="amount">转化比例,必须大于或等于 0。</param>
/// <returns>The <see cref="ColorMatrix"/>.</returns>
public static ColorMatrix CreateSaturationMatrix(float amount)
{
if (amount < 0)
{
throw new ArgumentOutOfRangeException(nameof(amount), "Threshold must be >= 0");
}
var matrix = new ColorMatrix();
matrix.Matrix00 = .213F + (.787F * amount);
matrix.Matrix10 = .715F - (.715F * amount);
matrix.Matrix20 = 1F - (matrix.Matrix00 + matrix.Matrix10);
matrix.Matrix01 = .213F - (.213F * amount);
matrix.Matrix11 = .715F + (.285F * amount);
matrix.Matrix21 = 1F - (matrix.Matrix01 + matrix.Matrix11);
matrix.Matrix02 = .213F - (.213F * amount);
matrix.Matrix12 = .715F - (.715F * amount);
matrix.Matrix22 = 1F - (matrix.Matrix02 + matrix.Matrix12);
matrix.Matrix33 = 1F;
return matrix;
}
}
}
Recommend
-
149
我们都知道如果把SVG嵌入到html中,可以使用fill来对SVG图片进行颜色填充;如果你使用css中的背景图片来引用SVG图片,那就无法使用fill来对SVG进行颜色填充。那还有其它的方法既要使用背景图片来引用SVG,又要改变它的颜色,这篇...
-
47
通过视频着色进行自监督跟踪 2018-07-18admin...
-
53
本文将介绍一门叫作 Web High Level Shading Language(WHLSL,发音为“whistle”)的新 Web 图形着色语言。它对 HLSL 进行了扩展,变得更安全、更可靠。 背景 在过去的几十年中,3D 图形已经发生了重大变化,程序员用...
-
64
-
60
-
23
在之前一章中我们了解了webgl中的一些常识,也尝试绘制了第一个webgl程序,接下来这一张会介绍一些webgl中的基本概念,包含顶点着色器、片元着色器、缓冲区 什么是顶点着色器和片元着色器 缓冲区
-
13
您现在的位置:首页 --> 其他 --> pptx,docx,xlsx 文件下载问题 pptx,docx,xlsx 文件下载问题
-
6
在PPT中,我们可以通过图片格式选项中->颜色->设置透明色,将指定颜色设置为透明,以实现去除纯色背景的需求。
-
8
【转】 PPTX解析 重新着色PPT对图片进行重新着色和设置透明颜色这两个行为,并不会对原图进行修改,而是通过将修改信息直接存入xml中,并在加载图片时通过计算将效果渲染出来。由于PPT不会存储一张经过该效果处理后的图片,...
-
6
美团人才管理手册与带兵工具.pptx Svip¥0.94
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK