.NET SixLabors.ImageSharp v1.0 图像实用程序控制台示例

使用 C# 控制台应用程序示例在 Windows、Linux 和 MacOS 机器上处理图像,包括创建散点图和直方图,以及根据需要旋转图像以便正确显示。
这个小型实用程序库需要将 NuGet SixLabors.ImageSharp包(版本 1.0.4)添加到.NET Core 3.1/ .NET 6 / .NET 8项目中。它与Windows、Linux和 MacOS兼容。
这已针对ImageSharp v3.0.1 进行了重新设计。
它可以根据百万像素数或长度乘以宽度来调整图像大小,并根据需要保留纵横比。
它根据EXIF数据旋转/翻转图像。这是为了适应移动设备。
它还创建散点图和直方图。
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Formats.Png;
using System.IO;
using System;
using SixLabors.ImageSharp.Formats.Jpeg;
namespace ImageUtil
{
public class GetSize
{
public GetSize(Stream stream)
{
using (Image iOriginal = Image.Load(stream))
{
stream.Position = 0;
Width = iOriginal.Width;
Height = iOriginal.Height;
}
}
/// <summary>
/// The width of the image specified in the class constructor's Stream parameter
/// </summary>
public int Width { get; }
/// <summary>
/// The height of the image specified in the class constructor's Stream parameter
/// </summary>
public int Height { get; }
}
public static class Resize
{
/// <summary>
/// Resize and save an image to a Stream specifying its new width and height
/// </summary>
public static void SaveImage(Stream imageStream, int newWidth, int newHeight, bool preserveImageRatio, Stream saveToStream, int jpegQuality = 100)
{
using (Image iOriginal = Image.Load(imageStream))
{
imageStream.Position = 0;
if (preserveImageRatio)
{
float percentWidth = newWidth / (float)iOriginal.Width;
float percentHeight = newHeight / (float)iOriginal.Height;
float percent = percentHeight < percentWidth ? percentHeight : percentWidth;
newWidth = (int)Math.Round(iOriginal.Width * percent, 0);
newHeight = (int)Math.Round(iOriginal.Height * percent, 0);
}
resize(imageStream, iOriginal, newWidth, newHeight, saveToStream, jpegQuality);
}
}
/// <summary>
/// Resize and save an image to a Stream specifying the number of pixels to resize to
/// </summary>
public static void SaveImage(Stream imageStream, int newNumberOfPixels, Stream saveToStream, int jpegQuality = 100)
{
using (Image iOriginal = Image.Load(imageStream))
{
imageStream.Position = 0;
double ratio = Math.Sqrt(newNumberOfPixels / (double)(iOriginal.Width * iOriginal.Height));
resize(imageStream, iOriginal, (int)Math.Round(iOriginal.Width * ratio, 0), (int)Math.Round(iOriginal.Height * ratio, 0), saveToStream, jpegQuality);
}
}
private static void resize(Stream origSource, Image image, int newWidth, int newHeight, Stream saveTo, int jpegQuality)
{
image.Mutate(x => x.Resize(newWidth, newHeight));
transformImage(image); // NOTE: transform image AFTER resizing it!!!
var format = Image.DetectFormat(origSource);
if (format.Name.ToLower() == "jpeg")
{
var encoder = new JpegEncoder();
encoder.Quality = jpegQuality;
image.SaveAsJpeg(saveTo, encoder);
}
else
image.Save(saveTo, format);
}
private static void transformImage(Image image)
{
IExifValue exifOrientation = image.Metadata?.ExifProfile?.GetValue(ExifTag.Orientation);
if (exifOrientation == null)
return;
RotateMode rotateMode;
FlipMode flipMode;
setRotateFlipMode(exifOrientation, out rotateMode, out flipMode);
image.Mutate(x => x.RotateFlip(rotateMode, flipMode));
image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, (ushort)1);
}
private static void setRotateFlipMode(IExifValue exifOrientation, out RotateMode rotateMode, out FlipMode flipMode)
{
var orientation = (ushort)exifOrientation.GetValue();
switch (orientation)
{
case 2:
rotateMode = RotateMode.None;
flipMode = FlipMode.Horizontal;
break;
case 3:
rotateMode = RotateMode.Rotate180;
flipMode = FlipMode.None;
break;
case 4:
rotateMode = RotateMode.Rotate180;
flipMode = FlipMode.Horizontal;
break;
case 5:
rotateMode = RotateMode.Rotate90;
flipMode = FlipMode.Horizontal;
break;
case 6:
rotateMode = RotateMode.Rotate90;
flipMode = FlipMode.None;
break;
case 7:
rotateMode = RotateMode.Rotate90;
flipMode = FlipMode.Vertical;
break;
case 8:
rotateMode = RotateMode.Rotate270;
flipMode = FlipMode.None;
break;
default:
rotateMode = RotateMode.None;
flipMode = FlipMode.None;
break;
}
}
}
/* CREATE A SCATTER PLOT JPEG/PNG IMAGE */
public static class ScatterPlot
{
static readonly Rgba32 WHITE = new Rgba32(255, 255, 255);
static readonly Rgba32 BLACK = new Rgba32(0, 0, 0);
static readonly Rgba32 RED = new Rgba32(255, 0, 0);
static readonly Rgba32 BLUE = new Rgba32(0, 0, 255);
static readonly Rgba32 GREEN = new Rgba32(0, 192, 0);
static readonly Rgba32 PURPLE = new Rgba32(128, 0, 128);
static readonly Rgba32 ORANGE = new Rgba32(255, 164, 0);
static readonly Rgba32 YELLOW = new Rgba32(255, 225, 0);
static readonly Rgba32 MAGENTA = new Rgba32(255, 0, 255);
static readonly Rgba32 AQUA = new Rgba32(0, 225, 255);
static readonly Rgba32 BLUEJEAN = new Rgba32(0, 128, 255);
static readonly Rgba32 BROWN = new Rgba32(150, 75, 50);
static readonly Rgba32 CHARTREUSE = new Rgba32(223, 255, 0);
static readonly Rgba32 DODGERBLUE = new Rgba32(30, 144, 255);
static readonly Rgba32 NAVY = new Rgba32(0, 0, 128);
static readonly Rgba32 DARKRED = new Rgba32(139, 0, 0);
static readonly Rgba32[] colors = new Rgba32[] { WHITE, BLACK, RED, BLUE, GREEN, PURPLE, ORANGE, YELLOW, MAGENTA, AQUA, BLUEJEAN, BROWN, DODGERBLUE, CHARTREUSE, NAVY, DARKRED };
public static void CreateJPEG(Stream stream, ScatterPlotColors backgroundColor, IEnumerable<PlotPoint> points, int width, int height, int pointSize, int jpegQuality = 100)
{
using (var bmp = new Image<Rgba32>(width / pointSize + 6, height / pointSize + 6, colors[(int)backgroundColor]))
create(stream, width, height, bmp, points, pointSize, new JpegEncoder() { Quality = jpegQuality });
}
public static void CreateJPEG(string filename, ScatterPlotColors backgroundColor, IEnumerable<PlotPoint> points, int width, int height, int pointSize, int jpegQuality = 100)
{
using (var stream = File.Create(filename))
CreateJPEG(stream, backgroundColor, points, width, height, pointSize, jpegQuality);
}
public static void CreatePNG(Stream stream, IEnumerable<PlotPoint> points, int width, int height, int pointSize)
{
using (var bmp = new Image<Rgba32>(width / pointSize + 6, height / pointSize + 6))
create(stream, width, height, bmp, points, pointSize, new PngEncoder());
}
public static void CreatePNG(string filename, IEnumerable<PlotPoint> points, int width, int height, int pointSize)
{
using (var stream = File.Create(filename))
CreatePNG(stream, points, width, height, pointSize);
}
private static double normalize(float min, float max, float value)
{
double x = max - min;
if(x == 0)
return 0;
return (value - min) / x;
}
private static void create(Stream stream, int width, int height, Image<Rgba32> bmp, IEnumerable<PlotPoint> points, int pointSize, SixLabors.ImageSharp.Formats.IImageEncoder imageEncoder)
{
float xMax = float.MinValue, xMin = float.MaxValue, yMax = float.MinValue, yMin = float.MaxValue;
foreach (var pt in points)
{
xMax = Math.Max(pt.x, xMax);
xMin = Math.Min(pt.x, xMin);
yMax = Math.Max(pt.y, yMax);
yMin = Math.Min(pt.y, yMin);
}
float xDelta = Math.Max(1, xMax - xMin), yDelta = Math.Max(1, yMax - yMin);
int w = width / pointSize;
int h = height / pointSize;
foreach (var pt in points)
{
int x = (int)(w * normalize(xMin, xMax, pt.x));
int y = (int)(h * normalize(yMin, yMax, pt.y));
bmp[x + 3, y + 3] = colors[((int)pt.color) % colors.Length];
}
bmp.Mutate(x => x.Flip(FlipMode.Vertical));
bmp.Mutate(x => x.Resize(width, height));
bmp.Save(stream, imageEncoder);
}
}
public class PlotPoint
{
public ScatterPlotColors color { get; }
public float x { get; }
public float y { get; }
public PlotPoint(float x, float y, ScatterPlotColors color)
{
this.x = x;
this.y = y;
this.color = color;
}
}
public enum ScatterPlotColors
{
WHITE,
BLACK,
RED,
BLUE,
GREEN,
PURPLE,
ORANGE,
YELLOW,
MAGENTA,
AQUA,
BLUEJEAN,
BROWN,
CHARTREUSE,
DODGERBLUE,
NAVY,
DARKRED
}
/* CREATE A PNG HISTOGRAM OF AN IMAGE */
public static class Histogram
{
/// <summary>
/// Create a histogram from the data in a stream
/// </summary>
public static MemoryStream CreatePNG(Stream stream, int width, int height, LRGB lrgb, byte alphaChannel = 128, bool clipBlackAndWhite = true, byte luminanceShade = 255)
{
using (var bmp = Image<Rgb24>.Load(stream))
{
return create(bmp, width, height, lrgb, alphaChannel, clipBlackAndWhite, luminanceShade);
}
}
/// <summary>
/// Create a histogram from the data in a file
/// </summary>
public static MemoryStream CreatePNG(string filename, int width, int height, LRGB lrgb, byte alphaChannel = 128, bool clipBlackAndWhite = true, byte luminanceShade = 255)
{
using (var bmp = Image<Rgb24>.Load(filename))
{
return create(bmp, width, height, lrgb, alphaChannel, clipBlackAndWhite, luminanceShade);
}
}
private static MemoryStream create(Image bmp, int width, int height, LRGB lrgb, byte alpha, bool clip, byte shade)
{
ulong[] lumin = new ulong[256];
ulong[] red = new ulong[256];
ulong[] green = new ulong[256];
ulong[] blue = new ulong[256];
var bred = (lrgb & LRGB.RED) != 0;
var bgreen = (lrgb & LRGB.GREEN) != 0;
var bblue = (lrgb & LRGB.BLUE) != 0;
var blumin = (lrgb == LRGB.LUMINANCE);
int w = bmp.Width;
int h = bmp.Height;
var bmp2 = bmp.CloneAs<Rgb24>();
for (int y = 0; y < h; y++)
{
Span<Rgb24> pixelRow = bmp2.GetPixelRowSpan(y);
for (int x = 0; x < w; x++)
{
var c = pixelRow[x];
lumin[(int)Math.Round((c.R + c.G + c.B) / 3.0)]++;
red[c.R]++;
green[c.G]++;
blue[c.B]++;
}
}
ulong max = 0;
int a = (clip ? 1 : 0), b = (clip ? 255 : 256);
for (int i = a; i < b; i++)
{
if (!blumin)
{
if (bred)
if (max < red[i])
max = red[i];
if (bgreen)
if (max < green[i])
max = green[i];
if (bblue)
if (max < blue[i])
max = blue[i];
}
else if (max < lumin[i])
max = lumin[i];
}
double HEIGHTFACTOR = 256.0 / max;
if (blumin)
{
using (var bmplum = new Image<Rgba32>(256, 256))
{
var penlum = new VerticalPen(new Rgba32(shade, shade, shade, alpha));
for (int i = 0; i < 256; i++)
penlum.Draw(bmplum, i, (int)(lumin[i] * HEIGHTFACTOR));
bmplum.Mutate(x => x.Resize(width, height));
MemoryStream ms = new MemoryStream();
bmplum.Save(ms, new PngEncoder());
return ms;
}
}
else
{
using (var bmppre = new Image<Rgba32>(256, 256))
{
Image<Rgba32>? bmpred = null, bmpgreen = null, bmpblue = null;
VerticalPen? penred = null, pengreen = null, penblue = null;
if (bred)
{
bmpred = new Image<Rgba32>(256, 256);
penred = new VerticalPen(new Rgba32(255, 0, 0, alpha));
}
if (bgreen)
{
bmpgreen = new Image<Rgba32>(256, 256);
pengreen = new VerticalPen(new Rgba32(0, 255, 0, alpha));
}
if (bblue)
{
bmpblue = new Image<Rgba32>(256, 256);
penblue = new VerticalPen(new Rgba32(0, 0, 255, alpha));
}
for (int i = 0; i < 256; i++)
{
if (bred)
penred.Draw(bmpred, i, (int)(red[i] * HEIGHTFACTOR));
if (bgreen)
pengreen.Draw(bmpgreen, i, (int)(green[i] * HEIGHTFACTOR));
if (bblue)
penblue.Draw(bmpblue, i, (int)(blue[i] * HEIGHTFACTOR));
}
if (bred)
{
bmppre.Mutate(x => x.DrawImage(bmpred, 1));
bmpred.Dispose();
}
if (bgreen)
{
bmppre.Mutate(x => x.DrawImage(bmpgreen, 1));
bmpgreen.Dispose();
}
if (bblue)
{
bmppre.Mutate(x => x.DrawImage(bmpblue, 1));
bmpblue.Dispose();
}
bmppre.Mutate(x => x.Resize(width, height));
MemoryStream ms = new MemoryStream();
bmppre.Save(ms, new PngEncoder());
return ms;
}
}
}
internal class VerticalPen
{
private readonly Rgba32 color;
public VerticalPen(Rgba32 color)
{
this.color = color;
}
public void Draw(Image<Rgba32> bmp, int row, int height)
{
if (height <= bmp.Height)
for (int y = height - 1; y >= 0; y--)
bmp[row, bmp.Height - 1 - y] = color;
}
}
public enum LRGB
{
LUMINANCE = 0,
RED = 1,
GREEN = 2,
BLUE = 4,
REDBLUE = 1 | 4,
REDGREEN = 1 | 2,
BLUEGREEN = 2 | 4,
REDGREENBLUE = 1 | 2 | 4
}
}
}
示例用法
另请参阅:Web 应用程序示例
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
if(args.Length > 0)
{
using (var openfs = System.IO.File.OpenRead(args[0]))
{
// NOTE: GET IMAGE SIZE
var size = new ImageUtil.GetSize(openfs);
System.Console.WriteLine("IMAGE SIZE: " + size.Width + " x " + size.Height);
if (args.Length > 1)
{
if (System.IO.File.Exists(args[1]))
System.IO.File.Delete(args[1]);
using (var savefs = System.IO.File.OpenWrite(args[1]))
{
System.Console.WriteLine("RESIZING IMAGE TO 10K PIXEL THUMBNAIL");
// NOTE: RESIZE IMAGE TO 10K PIXELS; THIS WILL ALSO FLIP AND ROTATE IMAGE AS NEEDED
ImageUtil.Resize.SaveImage(openfs, 10000, savefs);
}
}
}
System.Console.WriteLine("CREATING LUMINANCE HISTOGRAM: histogram.png");
// NOTE: CREATE HISTOGRAM WHICH IS RETURNED AS A MEMORY STREAM OF A PORTABLE NETWORK GRAPHICS (PNG) IMAGE FILE
using (var histogram = ImageUtil.Histogram.CreatePNG(args[0], 300, 150, ImageUtil.Histogram.LRGB.LUMINANCE, 128))
{
if (System.IO.File.Exists("histogram.png"))
System.IO.File.Delete("histogram.png");
System.IO.File.WriteAllBytes("histogram.png", histogram.ToArray());
}
}
else
System.Console.WriteLine("argument one is path to image, argument two [optional] is path to resized image");
}
}
}
如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。
相关文章:
.NET SixLabors.ImageSharp v1.0 图像实用程序控制台示例
使用 C# 控制台应用程序示例在 Windows、Linux 和 MacOS 机器上处理图像,包括创建散点图和直方图,以及根据需要旋转图像以便正确显示。 这个小型实用程序库需要将 NuGet SixLabors.ImageSharp包(版本 1.0.4)添加到.NET Core 3.1/ …...
【机器学习】线性回归与一元线性回归
线性回归与一元线性回归 V1.1线性回归问题线性方程的最优解一元线性回归一元线性回归的方程一元线性回归距离衡量方法一元线性回归的最优化求解一元线性回归的最小二乘法解法 V1.1 线性回归问题 线性回归问题就是找一条线或超平面,并使用线或超平面来描述数据分布…...
soular基础教程-使用指南
soular是TikLab DevOps工具链的统一帐号中心,今天来介绍如何使用 soular 配置你的组织、工作台,快速入门上手。  1. 账号管理 可以对账号信息进行多方面管理,包括分配不同的部门、用户组等,从而确保账号权限和职责…...
《Spring实战》(第6版)第1章 Spring起步
第1部分 Spring基础 第1章 Spring起步 1.1 什么是Spring Spring的核心是提供一个容器(container)。 称为Spring应用上下文(Spring application context)。 创建和管理应用的组件(bean),与上下文装配在一起。 Bean装配通过依赖注入(Dependency Injection,DI)。…...
PAT乙级真题 — 1084 外观数列(java)
外观数列是指具有以下特点的整数序列: d, d1, d111, d113, d11231, d112213111, ...它从不等于 1 的数字 d 开始,序列的第 n1 项是对第 n 项的描述。比如第 2 项表示第 1 项有 1 个 d,所以就是 d1;第 2 项是 1 个 d(对…...
I.MX6ull 看门狗
一、看门狗介绍 WatchDog是为了能够防止程序跑飞而使用的一种硬件模块。如果你的程序没有跑飞,那么你的程序会 定时的去喂看门狗;如果你的程序跑飞了,那么就不会再去喂狗了,如果超过了喂狗的时间,那么狗就会 自己生成一个信号来重…...
鲸鱼算法优化Transformer+KAN网络并应用于时序预测任务
😊😊😊欢迎来到本博客😊😊😊 本次博客内容将聚焦于深度学习的相关知识与实践 🎉作者简介:⭐️⭐️⭐️主要研究方向涵盖深度学习、计算机视觉等方向。 📝目前更新&#x…...
一维差分算法篇:高效处理区间加减
那么在正式介绍我们的一维差分的原理前,我们先来看一下一维差分所应用的一个场景,那么假设我们现在有一个区间为[L,R]的一个数组,那么我要在这个数组中的某个子区间比如[i,m] (L<i<m<R)进行一个加k值或者减去k值的一个操作ÿ…...
export关键字
注意点: 使用 export 和 import 时,确保你的JavaScript环境支持ES6模块 在JavaScript中,export 关键字主要用于模块化编程,允许你将代码的不同部分导出,使得其他模块可以通过 import 关键字来引入这些部分。这是ES6&a…...
【C++】基础入门(详解)
🌟 Hello,我是egoist2023! 🌍 种一棵树最好是十年前,其次是现在! 目录 输入&输出 缺省参数(默认参数) 函数重载 引用 概念及定义 特性及使用 const引用 与指针的关系 内联inline和nullptr in…...
【快速入门】Unity 常用组件(功能块)
欢迎关注 、订阅专栏 【unity 新手教程】谢谢你的支持!💜💜 文章目录 Unity 常用组件(功能块):Transform - 变换:坐标、朝向、大小Mesh Filter - 加载网格数据Mesh Renderer- 渲染网格Camera - …...
Nessus 工具使用全攻略
目录 一、Nessus:网络安全的坚固防线 二、Nessus 安装指南 (一)获取安装包 (二)安装流程 三、初次配置:开启 Nessus 的第一步 (一)账号注册 (二)激活 …...
1441. 用栈操作构建数组 中等
1441. 用栈操作构建数组 给你一个数组 target 和一个整数 n。每次迭代,需要从 list { 1 , 2 , 3 ..., n } 中依次读取一个数字。 请使用下述操作来构建目标数组 target : "Push":从 list 中读取一个新元素, 并将其推入…...
【Springboot知识】从零开始配置springfox
文章目录 配置过程1. 添加依赖2. 创建Swagger配置类3. 配置Swagger UI4. 自定义Swagger配置(可选)4.1 添加全局请求参数4.2 配置响应消息 5. 运行项目并访问Swagger UI6. 其他注意事项7. 使用Springfox 3.x(可选)总结 忽略登录验证…...
PHP代驾系统小程序
🚗 代驾系统 —— 安全、便捷、智能的出行新选择 🔧 一款基于先进ThinkPHPUniapp技术架构,匠心独运的代驾软件横空出世,微信小程序端率先登场,为您的出行之旅增添前所未有的便捷与安全。它不仅是您贴心的出行助手&…...
pg认证需要培训机构吗
认证类型决定是否需要培训机构 官方认证 PostgreSQL社区认证:PostgreSQL社区并未强制要求通过培训机构才能参加认证考试。例如,PostgreSQL Professional Certification(由社区认可的机构提供)通常允许考生自学后直接报名考试。 Po…...
网络安全扫描--基础篇
前言 1、了解互联网安全领域中日趋重要的扫描技术 2、了解在不同网络场景下扫描技术手段 3、熟悉linux下系统内核防护策略并能大件一个有效的系统防护体系 4、增强工作安全意识,并能有效的实践于工作场景中 目录 1、熟悉主机扫描工具(fping,…...
【MySQL数据库】Ubuntu下的mysql
目录 1,安装mysql数据库 2,mysql默认安装路径 3,my.cnf配置文件? 4,mysql运用的相关指令及说明 5,数据库、表的备份和恢复 mysql是一套给我们提供数据存取的,更加有利于管理数据的服务的网络程序。下…...
GPQA (Graduate-Level Google-Proof QA Benchmark) 数据集
标题:挑战人类与AI的极限:GPQA——一个面向未来的高难度科学问答基准 引言 在人工智能快速发展的今天,大型语言模型(如GPT-4)已能在许多任务中媲美甚至超越人类表现。然而,当面对需要高度专业知识的问题时&…...
WebRTC与EasyRTC:开启智能硬件音视频通讯的全新旅程
在当今数字化时代,音视频通讯技术正以前所未有的速度革新着我们的生活与工作方式。WebRTC与EasyRTC作为这一领域的佼佼者,正携手为智能硬件的音视频通讯注入强大动力,开启全新的篇章。 一、WebRTC与智能硬件融合的崭新趋势 WebRTC技术&…...
利用ffplay播放udp组播视频流
ffplay -fs -fflags nobuffer -flags low_delay -analyzeduration 0 -probesize 32 -framedrop -sync ext -strict experimental udp://224.1.1.1:5001 -fs : 全屏显示 -fflags nobuffer : 禁用输入缓冲(减少100-200ms缓冲延迟) -an…...
基于Ceedling的嵌入式软件单元测试
Ceedling 如果你使用 Ceedling(一个针对 C 代码单元测试的构建管理器),可以更方便地管理测试。Ceedling 会自动处理 Unity 和 CMock 的集成,无需手动编写 Makefile。 1.环境搭建 1.1 Ruby环境 sudo apt-get install ruby1.2 安…...
一文深入了解DeepSeek-R1:模型架构
本文深入探讨了 DeepSeek-R1 模型架构。让我们从输入到输出追踪 DeepSeek-R1 模型,以找到架构中的新发展和关键部分。DeepSeek-R1 基于 DeepSeek-V3-Base 模型架构。本文旨在涵盖其设计的所有重要方面。 📝 1. 输入上下文长度 DeepSeek-R1的输入上下文长…...
机试题——快乐时间
题目描述 小明在工作之余喜欢在电子书城阅读不同的书籍并且获得最大的满足感,因此根据书城针对每本书籍的评分收集了 n 个书籍的打分清单 books,例如第一本书的打分 books[0]5 代表该书的满意程度为 5,第二本书 books[1]-2 代表该书的满意程…...
2024年终总结和2025年规划
2024年的主线是AI基础的学习和读书,虽然AI学习花费了更多的时间,但是读书长久看来于我是更重要的事情,哈哈哈,因此先简单回顾一下读书记忆,回顾我的2024,再展望一下我的2025. 我的2024年记忆 读万卷书&am…...
5 .TCP传输 文件/数据
文件传输 本质:客户端通过标准IO或者文件IO,读取文件中的信息 然后将读取到的信息,通过套接字发送给服务器 服务器接收到后,立刻通过标准IO或者文件IO写到文件 这个过程,服务器要知道2件事 1:客户端发来的文件名字 …...
哈希表(典型算法思想)—— OJ例题算法解析思路
目录 一、1. 两数之和 - 力扣(LeetCode) 算法代码: 1. 问题描述 2. 核心思路 3. 代码实现思路 (1)初始化哈希表 (2)遍历数组 (3)返回结果 4. 时间复杂度分析 …...
CloudberryDB(七)二级索引
在CloudberryDB中,二级索引的概念与PostgreSQL中的类似。但是,由于分布式特性,创建和使用二级索引需要考虑一些额外的因素。以下是关于二级索引的一些要点: 1. **创建索引**:在Greenplum中,可以使用CREATE…...
学习web数据埋点
什么是埋点,以及为什么需要埋点 通过代码主动收集用户行为数据(如点击、浏览、停留时长等),用于数据分析驱动产品优化。 一、前端埋点 在客户端(浏览器、移动端应用)直接采集用户行为数据,通…...
Next.js【详解】CSS 样式方案
全局样式 Global CSS 默认已创建,即 src\app\globals.css,可根据需要修改 默认在全局布局中导入 src\app\layout.tsx import "./globals.css";组件样式 CSS Modules 新建文件 src\app\test\styles.module.css .red {color: red;}导入目标页面…...
