RGB565调色板Ver1.0.0
/**** RGB565 调色板****/
/**** 使用步骤
1 创建C#应用程序
2 再画图工具 截取 ‘编辑原色’ 保存为 RGB.png
3 复制本文代码。
4 在“pictureBox1”载入 RGB.png图片,然后编译即可
****/
/*****************************************************************************************
RGB565 调色板
功能:通过输入RGB值,或者拖动滚条,分别显示RGB和合成的颜色
编者:张永辉 2013年4月16日 第一个版本
*****************************************************************************************/
//Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace cs_test3
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new RGB565调试板());
}
}
}
/****************************************************************************************/
//Form1.cs
sing System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace cs_test3
{
public partial class RGB565调试板 : Form
{
public RGB565调试板()
{
InitializeComponent();
R = 0;
G = 0;
B = 0;
DisColorNew();
textBox3_r.Text = "0";
textBox_g.Text = "0";
textBox_b.Text = "0";
}
//三颜色定义
int R;
int G;
int B;
//----------------刷新颜色函数--------------------------------
private void DisColorNew()
{
Color c = Color.FromArgb(R, G, B);
richTextBox1.BackColor = c; //合成颜色
int rgb = ((R >> 3) << 11) + ((G >> 2) << 5) + (B >> 3);
textBox_RGB.Text = rgb.ToString();
c = Color.FromArgb(R, 0, 0); //R
textBox_RR.BackColor = c;
c = Color.FromArgb(0, G, 0); //G
textBox_GG.BackColor = c;
c = Color.FromArgb(0, 0, B); //B
textBox_BB.BackColor = c;
}
//通过拖动条改变颜色
//R
private void trackBar_r_Scroll(object sender, EventArgs e)
{
int c = trackBar_r.Value; //获取设定值
if (c > 31) //5位红色 0--31
{
c = 31;
}
textBox3_r.Text = c.ToString(); //显示值
c = c << 3;
R = c;
DisColorNew(); //刷新颜色
}
//G
private void trackBar_g_Scroll(object sender, EventArgs e)
{
int c = trackBar_g.Value;
if (c > 63)
{
c = 63;
}
textBox_g.Text = c.ToString();
c = c << 2;
G = c;
DisColorNew();
}
//B
private void trackBar_b_Scroll(object sender, EventArgs e)
{
int c = trackBar_b.Value;
if (c > 31)
{
c = 31;
}
textBox_b.Text = c.ToString();
c = c << 3;
B = c;
DisColorNew();
}
//----------------通过输入数字调整原色--------------------------
//R
private void textBox3_r_TextChanged(object sender, EventArgs e)
{
string str = textBox3_r.Text;
int c;
int.TryParse(str, out c);
if (c > 31) //5位红色 0--31
{
c = 31;
}
trackBar_r.Value = c; //刷新 拖动条
c = c << 3;
R = c;
DisColorNew(); //刷新颜色
}
private void textBox_g_TextChanged(object sender, EventArgs e)
{
string str = textBox_g.Text;
int c;
int.TryParse(str, out c);
if (c > 63)
{
c = 63;
}
trackBar_g.Value = c;
c = c << 2;
G = c;
DisColorNew();
}
private void textBox_b_TextChanged(object sender, EventArgs e)
{
string str = textBox_b.Text;
int c;
int.TryParse(str, out c);
if (c > 31)
{
c = 31;
}
trackBar_b.Value = c;
c = c << 3;
B = c;
DisColorNew();
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
string S = pictureBox1.BackColor.B.ToString();
S = pictureBox1.SizeMode.ToString();
}
}
}
/****************************************************************************************/
//Form1.Designer.cs
namespace cs_test3
{
partial class RGB565调试板
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.trackBar_r = new System.Windows.Forms.TrackBar();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.trackBar_g = new System.Windows.Forms.TrackBar();
this.trackBar_b = new System.Windows.Forms.TrackBar();
this.textBox_b = new System.Windows.Forms.TextBox();
this.textBox_g = new System.Windows.Forms.TextBox();
this.textBox3_r = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox_RR = new System.Windows.Forms.TextBox();
this.textBox_GG = new System.Windows.Forms.TextBox();
this.textBox_BB = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.textBox_RGB = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.trackBar_r)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar_g)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar_b)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// trackBar_r
//
this.trackBar_r.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.trackBar_r.Location = new System.Drawing.Point(31, 57);
this.trackBar_r.Maximum = 31;
this.trackBar_r.Name = "trackBar_r";
this.trackBar_r.Size = new System.Drawing.Size(222, 45);
this.trackBar_r.TabIndex = 2;
this.trackBar_r.Scroll += new System.EventHandler(this.trackBar_r_Scroll);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(320, 57);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(107, 141);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
//
// trackBar_g
//
this.trackBar_g.Location = new System.Drawing.Point(31, 134);
this.trackBar_g.Maximum = 63;
this.trackBar_g.Name = "trackBar_g";
this.trackBar_g.Size = new System.Drawing.Size(222, 45);
this.trackBar_g.TabIndex = 3;
this.trackBar_g.Scroll += new System.EventHandler(this.trackBar_g_Scroll);
//
// trackBar_b
//
this.trackBar_b.Location = new System.Drawing.Point(31, 219);
this.trackBar_b.Maximum = 31;
this.trackBar_b.Name = "trackBar_b";
this.trackBar_b.Size = new System.Drawing.Size(222, 45);
this.trackBar_b.TabIndex = 4;
this.trackBar_b.Scroll += new System.EventHandler(this.trackBar_b_Scroll);
//
// textBox_b
//
this.textBox_b.AllowDrop = true;
this.textBox_b.Location = new System.Drawing.Point(40, 192);
this.textBox_b.Name = "textBox_b";
this.textBox_b.Size = new System.Drawing.Size(63, 21);
this.textBox_b.TabIndex = 6;
this.textBox_b.TextChanged += new System.EventHandler(this.textBox_b_TextChanged);
//
// textBox_g
//
this.textBox_g.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.textBox_g.Location = new System.Drawing.Point(40, 105);
this.textBox_g.Name = "textBox_g";
this.textBox_g.Size = new System.Drawing.Size(63, 21);
this.textBox_g.TabIndex = 7;
this.textBox_g.TextChanged += new System.EventHandler(this.textBox_g_TextChanged);
//
// textBox3_r
//
this.textBox3_r.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.textBox3_r.Location = new System.Drawing.Point(40, 30);
this.textBox3_r.Name = "textBox3_r";
this.textBox3_r.Size = new System.Drawing.Size(63, 21);
this.textBox3_r.TabIndex = 8;
this.textBox3_r.TextChanged += new System.EventHandler(this.textBox3_r_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(122, 30);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(11, 12);
this.label1.TabIndex = 9;
this.label1.Text = "R";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(124, 105);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(11, 12);
this.label2.TabIndex = 10;
this.label2.Text = "G";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(126, 192);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(11, 12);
this.label3.TabIndex = 11;
this.label3.Text = "B";
//
// textBox_RR
//
this.textBox_RR.Location = new System.Drawing.Point(202, 30);
this.textBox_RR.Name = "textBox_RR";
this.textBox_RR.Size = new System.Drawing.Size(51, 21);
this.textBox_RR.TabIndex = 12;
//
// textBox_GG
//
this.textBox_GG.Location = new System.Drawing.Point(202, 105);
this.textBox_GG.Name = "textBox_GG";
this.textBox_GG.Size = new System.Drawing.Size(51, 21);
this.textBox_GG.TabIndex = 13;
//
// textBox_BB
//
this.textBox_BB.Location = new System.Drawing.Point(202, 192);
this.textBox_BB.Name = "textBox_BB";
this.textBox_BB.Size = new System.Drawing.Size(51, 21);
this.textBox_BB.TabIndex = 14;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(338, 210);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(77, 12);
this.label4.TabIndex = 15;
this.label4.Text = "zhangyonghui";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(308, 231);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(107, 12);
this.label5.TabIndex = 16;
this.label5.Text = "ver1.0.0 20130416";
//
// pictureBox1
//
this.pictureBox1.Image = global::cs_test3.Properties.Resources.RGB;
this.pictureBox1.Location = new System.Drawing.Point(457, 27);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(210, 186);
this.pictureBox1.TabIndex = 17;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick);
//
// textBox_RGB
//
this.textBox_RGB.Location = new System.Drawing.Point(320, 27);
this.textBox_RGB.Name = "textBox_RGB";
this.textBox_RGB.Size = new System.Drawing.Size(100, 21);
this.textBox_RGB.TabIndex = 18;
//
// RGB565调试板
//
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(706, 280);
this.Controls.Add(this.textBox_RGB);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox_BB);
this.Controls.Add(this.textBox_GG);
this.Controls.Add(this.textBox_RR);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox3_r);
this.Controls.Add(this.textBox_g);
this.Controls.Add(this.textBox_b);
this.Controls.Add(this.trackBar_b);
this.Controls.Add(this.trackBar_g);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.trackBar_r);
this.Name = "RGB565调试板";
((System.ComponentModel.ISupportInitialize)(this.trackBar_r)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar_g)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar_b)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TrackBar trackBar_r;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.TrackBar trackBar_g;
private System.Windows.Forms.TrackBar trackBar_b;
private System.Windows.Forms.TextBox textBox_b;
private System.Windows.Forms.TextBox textBox_g;
private System.Windows.Forms.TextBox textBox3_r;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox_RR;
private System.Windows.Forms.TextBox textBox_GG;
private System.Windows.Forms.TextBox textBox_BB;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TextBox textBox_RGB;
}
}
RGB565调色板Ver1.0.0相关推荐
- 富盛Sbo插件集Ver1.2.0 简介及免费下载
如果您希望得到富盛Sbo插件集Ver1.2.0软件的服务器安装软件,请给我来信. 对原来的富盛Sbo Addon开发框架进行了扩充和功能加强,并实现了一系列的具体业务,将这些业务整理成集,定名为富盛S ...
- 自己写的C盘清理工具 Ver1.0.0
自己写的一款清理C盘工具Ver 1.0.0 最近发现不少人的C盘红的要命! 于是我决定写一款C盘清理程序 送代码: using System; using System.IO; using Syste ...
- Zabbix 4.0.0 新功能介绍
改进仪表板 仪表板在新版本中有了进一步的改进,使其更有吸引力,更灵活,更能满足用户的需要. 为实现新的外观和功能,已取得以下进展: 一种新的更通用的基于SVG的图形小部件已经添加,而经典的设计图小部件 ...
- OpenCV中文文档4.0.0学习笔记(更新中……)
系列文章目录 文章目录 系列文章目录 前言 一.简介 1.OpenCV-Python教程简介 2.OpenCV-Python 3.OpenCV-Python教程 4.OpenCV 需要你!!! 二.G ...
- 子佩短信管家 v1.0.0
类型:系统工具 版本:v1.0.0 大小:13.9M 更新:2019/3/1 语言:简体 等级: 平台:安卓, 4.0以上 下载地址: 子佩短信管家 v1.0.0(1) 子佩短信管家 v1.0.0(2 ...
- ERROR: Failed to resolve: com.android.support:appcompat-v7:29.0.0
错误内容如下 ERROR: Failed to resolve: com.android.support:appcompat-v7:29.0.0 Show in Project Structure d ...
- No cached version of com.android.tools.build:gradle:2.0.0 available for offline mode.
异常场景 从AS2.0升级到2.1,重新编译工程后,抛出了如下异常 Error:A problem occurred configuring root project 'AndroidStudioPr ...
- Can't connect to MySQL server on '127.0.0.1' (10061) (code 2003)解决方法
先验证一下MySQL的服务是否开启,到计算机->管理->服务和应用程序->服务 如果服务已开启,就检查一下C:\WINDOWS\system32\drivers\etc目录下的hos ...
- pycharm中报错:Error: failed to send plot to http://127.0.0.1:63342
pycharm中报错:Error: failed to send plot to http://127.0.0.1:63342 import matplotlib.pyplot as plt impo ...
最新文章
- 如何通过深度学习,完成计算机视觉中的所有工作?
- 新来的同事问我 where 1=1 是什么意思
- Chronometer的使用
- Java设计模式 - 适配器模式
- 请你讲一讲JavaScript有哪些数据类型, 数据类型判断有哪些方法?
- 05-按钮的基本使用-开发步骤
- 【LeetCode】4月4日打卡-Day20-接雨水
- Tensorflow一些常用基本概念与函数(4)
- Cross-Site Scripting(XSS): 跨站脚本攻击介绍
- c mysql 包含字符串_Mysql字符串字段判断是否包含某个字符串的2种方法
- 制作一个简单HTML公司官网网页设计(HTML+CSS)
- python画图入门——for循环及调色盘的应用
- anaconda离线安装pytorch
- 计算机专硕双导师,【计算机专业论文】双导师制人才培养计算机专业论文(共1315字)...
- An invalid domain [] was specified for this cookie问题解决方案
- 《我喜欢生命本来的样子》读后感作文2100字
- 尤雨溪:重头来过的 Vue3 带来了什么?
- 2008年胡润中国富豪榜榜单(401-500名)
- idea使用Protobuf插件
- python nodejs开发web_用nodejs和python实现一个爬虫来爬网站(智联招聘)的信息