<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1873827350411866323</id><updated>2024-09-12T01:35:23.821+09:00</updated><category term="c#"/><category term="バーコードソフト"/><category term="check digit"/><title type='text'>ゴミ箱</title><subtitle type='html'>Microsoftだいすき</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>31</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-3606955552626786764</id><published>2019-09-07T14:19:00.000+09:00</published><updated>2020-07-22T00:46:14.025+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><title type='text'>C# グリッド状に配置したTextBoxをカーソルキーで移動したい！</title><content type='html'>必要に駆られて書いたので覚書&lt;br /&gt;
もっとかんたんなほうほうあるんやろか&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinNyjYFfOy0emHtZ4XfkIYZ6stztmgm6Sdko2Q-pUFLRod8Jthg6xtVnA3ebxXbTPjajODslsk1yQT4hZNVwYS4Uv6MaRP1zpshmH-JBRzh-u3k6Tl8br5uUlqEXuLRzfH4V4TzSjjjche/s1600/GIF.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;369&quot; data-original-width=&quot;464&quot; height=&quot;254&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinNyjYFfOy0emHtZ4XfkIYZ6stztmgm6Sdko2Q-pUFLRod8Jthg6xtVnA3ebxXbTPjajODslsk1yQT4hZNVwYS4Uv6MaRP1zpshmH-JBRzh-u3k6Tl8br5uUlqEXuLRzfH4V4TzSjjjche/s320/GIF.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        List&lt;textbox&gt; textBoxList = new List&lt;textbox&gt;();

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (var item in this.Controls)
            {
                if (item is TextBox) textBoxList.Add(item as TextBox);
            }

            textBoxList.ForEach(x =&gt; x.KeyDown += X_KeyDown);
            textBoxList.ForEach(x =&gt; x.Text = &quot;hogehoge&quot;);
        }

        private void X_KeyDown(object sender, KeyEventArgs e)
        {
            var t = sender as TextBox;
            TextBox nextControl;
            switch (e.KeyCode)
            {
                case Keys.Left:
                    if (t.SelectionStart != 0 &amp;&amp; t.SelectionLength != t.Text.Length) return;//文字列編集途中なら抜ける

                    nextControl = textBoxList.Where(x =&gt; t.Location.X - 5 &gt; x.Location.X)
                        .OrderBy(x =&gt; getDistance(t.Location.X, t.Location.Y, x.Location.X, x.Location.Y)).FirstOrDefault();

                    if (nextControl != null)
                    {
                        nextControl.Focus();
                        nextControl.SelectAll();
                    }

                    break;
                case Keys.Up:
                    nextControl = textBoxList.Where(x =&gt; t.Location.Y - 5 &gt; x.Location.Y)
                        .OrderBy(x =&gt; getDistance(t.Location.X, t.Location.Y, x.Location.X, x.Location.Y)).FirstOrDefault();

                    if (nextControl != null)
                    {
                        nextControl.Focus();
                        nextControl.SelectAll();
                    }
                    break;
                case Keys.Right:
                    if (t.SelectionStart != t.TextLength  &amp;&amp; t.SelectionLength != t.Text.Length) return;//文字列編集途中なら抜ける
                    
                    nextControl = textBoxList.Where(x =&gt; t.Location.X + 5 &lt; x.Location.X)
                        .OrderBy(x =&gt; getDistance(t.Location.X, t.Location.Y, x.Location.X, x.Location.Y)).FirstOrDefault();

                    if (nextControl != null)
                    {
                        nextControl.Focus();
                        nextControl.SelectAll();
                    }
                    break;
                case Keys.Down:
                    nextControl = textBoxList.Where(x =&gt; t.Location.Y + 5 &lt; x.Location.Y)
                        .OrderBy(x =&gt; getDistance(t.Location.X, t.Location.Y, x.Location.X, x.Location.Y)).FirstOrDefault();

                    if (nextControl != null)
                    {
                        nextControl.Focus();
                        nextControl.SelectAll();
                    }
                    break;
            }

        }

        private double getDistance(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        }
    }

&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
最初からDataGrid系のコントロールを使えばよかった・・・&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/3606955552626786764/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2019/09/c-textbox.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/3606955552626786764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/3606955552626786764'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2019/09/c-textbox.html' title='C# グリッド状に配置したTextBoxをカーソルキーで移動したい！'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinNyjYFfOy0emHtZ4XfkIYZ6stztmgm6Sdko2Q-pUFLRod8Jthg6xtVnA3ebxXbTPjajODslsk1yQT4hZNVwYS4Uv6MaRP1zpshmH-JBRzh-u3k6Tl8br5uUlqEXuLRzfH4V4TzSjjjche/s72-c/GIF.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-5214530340375944982</id><published>2014-08-10T00:09:00.000+09:00</published><updated>2014-08-10T00:09:04.192+09:00</updated><title type='text'>MarkdownNote0.0.0.2</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
今日も更新&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
検索/置換/表の挿入機能の追加&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho-W5nte53-mivbBdJ5KU4GkdUJANEV9LUZ3a9sUjmabAaOSY4sEKxMnGgcOrGg6i_jSjqc82z9-eJA_O5_z4d3j5zadtLam_0dgA_RJ7dGRzaXm8Nn2AnO-ohkh7b72FOMtZNd1UGM_0v/s1600/markdownnote0002.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho-W5nte53-mivbBdJ5KU4GkdUJANEV9LUZ3a9sUjmabAaOSY4sEKxMnGgcOrGg6i_jSjqc82z9-eJA_O5_z4d3j5zadtLam_0dgA_RJ7dGRzaXm8Nn2AnO-ohkh7b72FOMtZNd1UGM_0v/s1600/markdownnote0002.png&quot; height=&quot;195&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
今後の予定&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
プレビューがあやしい＆使えなくしてる機能の修正&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
ファイルのエンコードを変更できるように&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
シンタックスハイライトの追加&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
見出しの一覧/移動ができるように&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
怪しい英語から日本語へ切り替えれるようにLanguageファイルの追加&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/5214530340375944982/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/08/markdownnote0002.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5214530340375944982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5214530340375944982'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/08/markdownnote0002.html' title='MarkdownNote0.0.0.2'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho-W5nte53-mivbBdJ5KU4GkdUJANEV9LUZ3a9sUjmabAaOSY4sEKxMnGgcOrGg6i_jSjqc82z9-eJA_O5_z4d3j5zadtLam_0dgA_RJ7dGRzaXm8Nn2AnO-ohkh7b72FOMtZNd1UGM_0v/s72-c/markdownnote0002.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-244072855786195594</id><published>2014-08-08T00:21:00.002+09:00</published><updated>2014-08-10T00:01:21.493+09:00</updated><title type='text'>MarkdownNote0.0.0.1</title><content type='html'>&lt;br /&gt;
最近Markdown記法にハマっているのでタブ切り替え型のエディターを作成中&lt;br /&gt;
とりあえず形になってきたのでうｐしてみました&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd4Ow-d-duOl1WJnaLQ8TDTbu9JNR5B04NIVruSqzp4jelGbpwVbTYEy3rFEgtjk3jF7MggwcdhXsFjRscW6vNM86ISW4Sr-UOx5xrIjR3mS_nAQxhXaf9sAHXTV79l8lCJlYr5GKCNQNq/s1600/markdownnote0001.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd4Ow-d-duOl1WJnaLQ8TDTbu9JNR5B04NIVruSqzp4jelGbpwVbTYEy3rFEgtjk3jF7MggwcdhXsFjRscW6vNM86ISW4Sr-UOx5xrIjR3mS_nAQxhXaf9sAHXTV79l8lCJlYr5GKCNQNq/s320/markdownnote0001.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
動作には.netFramework4.0以上が必要です&lt;br /&gt;
&lt;a href=&quot;http://komozo.blogspot.jp/p/blog-page_2.html&quot;&gt;ここからダウンロード&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/244072855786195594/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/08/markdown.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/244072855786195594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/244072855786195594'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/08/markdown.html' title='MarkdownNote0.0.0.1'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd4Ow-d-duOl1WJnaLQ8TDTbu9JNR5B04NIVruSqzp4jelGbpwVbTYEy3rFEgtjk3jF7MggwcdhXsFjRscW6vNM86ISW4Sr-UOx5xrIjR3mS_nAQxhXaf9sAHXTV79l8lCJlYr5GKCNQNq/s72-c/markdownnote0001.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-8035216677405290232</id><published>2014-04-23T23:52:00.000+09:00</published><updated>2014-04-24T00:30:49.447+09:00</updated><title type='text'>引き継いだAccessのシステムが激遅な件</title><content type='html'>15年近く前に外注に出したAccessのシステムの保守を引き継いだ&lt;br /&gt;
データのサイズは400MBを超えていて、数万件のデータから1レコードを検索をしようと思ったら1分近くかかるシステムだった。&lt;br /&gt;
外注の書いたコードか前任者の追加コードが原因かは今となってはわからない（仕様書もない）が&lt;br /&gt;
VBAソースコードを見直してみたらナポリタンの匂いがした&lt;br /&gt;
&lt;br /&gt;
TCP Monitor Plusをダウンロードして、ファイルサーバーとクライアントPCのパケットをモニタリングしてみたところ1レコードの検索で80MBのデータを受信していることが判明(/・ω・)/&lt;br /&gt;
&lt;br /&gt;
見直しをしてみたらテーブルのフィールドに適切なインデックスが設定されておらずRecordsetでFilter使いまくりだった&lt;br /&gt;
&lt;br /&gt;
Indexの有無とFilter使った場合でどんだけ違うのかをテストしてみた&lt;br /&gt;
&lt;br /&gt;
新しいAccessファイルを作りテーブル１にフィールド1～6を追加&lt;br /&gt;
フィールド1はインデックスをはい (重複あり)に指定&lt;br /&gt;
&lt;br /&gt;
下のコードで500000件のテストデータを入れ込んだ&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;VB&quot; name=&quot;code&quot;&gt;Option Compare Database
Option Explicit

Sub TestData()

    Dim db As DAO.Database
    Set db = CurrentDb
  
    Dim l As Long
    For l = 0 To 500000
      
        db.Execute (&quot;INSERT INTO テーブル1 (フィールド1,フィールド2,フィールド3,フィールド4,フィールド5,フィールド6) &quot; &amp; _
                    &quot;VALUES (&#39;&quot; &amp; GetGUID() &amp; &quot;&#39;,&#39;&quot; &amp; GetGUID() &amp; &quot;&#39;,&#39;&quot; &amp; GetGUID() &amp; &quot;&#39;,&#39;&quot; &amp; GetGUID() &amp; &quot;&#39;,&#39;&quot; &amp; GetGUID() &amp; &quot;&#39;,&#39;&quot; &amp; GetGUID() &amp; &quot;&#39;)&quot;)
  
    Next

End Sub

&#39;下のサイトを参考にさせてもらいました
&#39;http://maeda0414.blog.fc2.com/blog-entry-26.html
Public Function GetGUID() As String
    GetGUID = Mid$(CreateObject(&quot;Scriptlet.TypeLib&quot;).Guid, 2, 36)
End Function
&lt;/pre&gt;このファイルをファイルサーバに置き&lt;br /&gt;
クライアント側にも新しいAccessファイルを作りモジュールに下のテストコードを書く&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;VB&quot; name=&quot;code&quot;&gt;Option Compare Database
Option Explicit

Public Sub Test1()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
  
    Set db = CurrentDb
  
    &#39;インデックスを設定したフィールドを条件にして直にクエリ文を書いた
    Set rs = db.OpenRecordset(&quot;SELECT * FROM テーブル1 WHERE フィールド1 = &#39;884EBDD8-0516-480D-9C13-6F2EF60B2202&#39;&quot;)
    
    Do Until rs.EOF
        Debug.Print (&quot;Test1 &quot; &amp; rs!ID)
        rs.MoveNext
    Loop
  
End Sub

Public Sub Test2()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
  
    Set db = CurrentDb
  
    &#39;インデックスの設定をしていないフィールドを条件にして直にクエリ文を書いた
    Set rs = db.OpenRecordset(&quot;SELECT * FROM テーブル1 WHERE フィールド2 = &#39;7BFD061C-711E-404F-89D3-0973CADFF5F6&#39;&quot;)
    
    Do Until rs.EOF
        Debug.Print (&quot;Test2 &quot; &amp; rs!ID)
        rs.MoveNext
    Loop
      
End Sub

Public Sub Test3()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
  
    Set db = CurrentDb
  
    &#39;Filterプロパティにインデックスを設定したフィールドの条件を書いた
    Set rs = db.OpenRecordset(&quot;テーブル1&quot;)
    rs.Filter = &quot;フィールド1 = &#39;884EBDD8-0516-480D-9C13-6F2EF60B2202&#39;&quot;
    Set rs = rs.OpenRecordset
    
    Do Until rs.EOF
        Debug.Print (&quot;Test3 &quot; &amp; rs!ID)
        rs.MoveNext
    Loop
  
End Sub

Public Sub Test4()
  
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
  
    Set db = CurrentDb
  
    &#39;Filterプロパティにインデックスの設定していないフィールドの条件を書いた
    Set rs = db.OpenRecordset(&quot;SELECT * FROM テーブル1 WHERE フィールド2 = &#39;7BFD061C-711E-404F-89D3-0973CADFF5F6&#39;&quot;)
    
    Set rs = db.OpenRecordset(&quot;テーブル1&quot;)
    rs.Filter = &quot;フィールド2 = &#39;7BFD061C-711E-404F-89D3-0973CADFF5F6&#39;&quot;
    Set rs = rs.OpenRecordset
    Do Until rs.EOF
        Debug.Print (&quot;Test4 &quot; &amp; rs!ID)
        rs.MoveNext
    Loop
      
End Sub
&lt;/pre&gt;&lt;br /&gt;
リンクテーブルを張ってテスト&lt;br /&gt;
&lt;br /&gt;
結果&lt;br /&gt;
Test1 送受信量&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;226KB&lt;br /&gt;
Test2 送受信量&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;153MB&lt;br /&gt;
Test3 送受信量&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;157MB&lt;br /&gt;
Test4 送受信量&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;157MB&lt;br /&gt;
&lt;br /&gt;
まとめ&lt;br /&gt;
適切なインデックス設定を行う事とRecordsetのFilterは使わないと心に誓った</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/8035216677405290232/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/04/access.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/8035216677405290232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/8035216677405290232'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/04/access.html' title='引き継いだAccessのシステムが激遅な件'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-850889057232337212</id><published>2014-03-12T00:52:00.001+09:00</published><updated>2014-03-12T00:52:18.466+09:00</updated><title type='text'>忘れていた</title><content type='html'>ブログが三日坊主になっていたので更新&lt;br /&gt;
モジュラス103もそのうち更新するよてえい&lt;br /&gt;
&lt;br /&gt;
電子タバコおいしいれす（＾q＾）</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/850889057232337212/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/850889057232337212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/850889057232337212'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/blog-post.html' title='忘れていた'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-6522010568803254135</id><published>2014-03-12T00:46:00.001+09:00</published><updated>2014-03-12T09:21:36.683+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#で9DSRの計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// 9DSR　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string Get9DSR(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result)
    {
        return null;
    }
    return (ulong.Parse(Value) % 9 == 0 ? 0 : 9 - (int.Parse(Value) % 9)).ToString();
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/6522010568803254135/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/9dsr.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/6522010568803254135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/6522010568803254135'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/9dsr.html' title='C#で9DSRの計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-2672798385863679413</id><published>2014-03-12T00:32:00.002+09:00</published><updated>2014-03-12T09:21:53.979+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#でルーンズ（モジュラス10/ウェイト2）の計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// ルーンズ（モジュラス10/ウェイト2　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string GetModulus10Weight2Runes(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result)
    {
        return null;
    }

    long checkDigit = 0;

    for (int i = 0; i &amp;lt; Value.Length; i++)
    {
        if (i % 2 == 0)
        {
            int x = int.Parse(Value.Substring(Value.Length - 1 - i, 1)) * 2;
            //１０以上の場合、桁ごとに加算
            if (10 &amp;lt;= x) x = 1 + (x % 10);

            checkDigit += x;
        }
        else
        {
            checkDigit += int.Parse(Value.Substring(Value.Length - 1 - i, 1));
        }
    }

    checkDigit = 10 - (checkDigit % 10);

    checkDigit = checkDigit == 10 ? 0 : checkDigit;

    return checkDigit.ToString();
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/2672798385863679413/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/102_12.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/2672798385863679413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/2672798385863679413'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/102_12.html' title='C#でルーンズ（モジュラス10/ウェイト2）の計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-7808702447988283891</id><published>2014-03-12T00:31:00.005+09:00</published><updated>2014-03-12T09:22:05.238+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#で加重モジュラス11の計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// 加重モジュラス11 計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string GetWeightedModulus11(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result || Value.Length &amp;gt; 12)
    {
        return null;
    }

    int[] weight1 = { 2, 6, 3, 5, 4, 8, 7, 10, 9, 5, 3, 6, };
    int[] weight2 = { 9, 5, 8, 6, 7, 3, 4, 10, 2, 6, 8, 5, };

    try
    {
        int checkDigit = 0;
        for (int i = 0; i &amp;lt; 2; i++)
        {
            checkDigit = 0;
            for (int j = 0; j &amp;lt; Value.Length; j++)
            {
                checkDigit += int.Parse(Value.Substring(Value.Length - 1 - j, 1)) * (i == 0 ? weight1[j] : weight2[j]);
            }
            checkDigit = checkDigit % 11;

            if (checkDigit == 0) return &quot;0&quot;;
            if (checkDigit != 1) break;
        }

        return (11 - checkDigit).ToString();
    }
    catch
    { }
    return null;
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/7808702447988283891/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/11_12.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/7808702447988283891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/7808702447988283891'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/11_12.html' title='C#で加重モジュラス11の計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-1352032242889064514</id><published>2014-03-12T00:31:00.002+09:00</published><updated>2014-03-12T09:22:16.194+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#でモジュラス10/ウェイト2の計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// モジュラス10/ウェイト2　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string GetModulus10Weight2(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result)
    {
        return null;
    }

    int checkDigit = 0;

    for (int i = 0; i &amp;lt; Value.Length; i++)
    {
        checkDigit += int.Parse(Value.Substring(Value.Length - 1 - i, 1)) * (i % 2 == 0 ? 2 : 1);
    }

    checkDigit = 10 - (checkDigit % 10);

    checkDigit = checkDigit == 10 ? 0 : checkDigit;

    return checkDigit.ToString();
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/1352032242889064514/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/102.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/1352032242889064514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/1352032242889064514'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/102.html' title='C#でモジュラス10/ウェイト2の計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-1792640368192116484</id><published>2014-03-12T00:30:00.006+09:00</published><updated>2014-03-12T09:22:26.200+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#でモジュラス11の計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// モジュラス11　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string GetModulus11(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result || 6 &amp;gt; Value.Length)
    {
        return null;
    }

    string val = Value.Substring(0, 6);

    int checkDigit = 0;
    for (int i = 0; i &amp;lt; val.Length; i++)
    {
        checkDigit += int.Parse(val.Substring(i, 1)) * (7 - i);
    }
    checkDigit = checkDigit % 11;

    if (checkDigit == 0)
    {
        return &quot;1&quot;;
    }
    else if (checkDigit == 1)
    {
        return &quot;0&quot;;
    }
    else
    {
        return (11 - checkDigit).ToString();
    }
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/1792640368192116484/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/11.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/1792640368192116484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/1792640368192116484'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/11.html' title='C#でモジュラス11の計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-5391756625829186369</id><published>2014-03-12T00:30:00.002+09:00</published><updated>2014-03-12T09:23:08.156+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#で9DRの計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// 9DR　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string Get9DR(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result)
    {
        return null;
    }

    return (ulong.Parse(Value) % 9).ToString();
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/5391756625829186369/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/c9dr.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5391756625829186369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5391756625829186369'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/c9dr.html' title='C#で9DRの計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-53095728009665481</id><published>2014-03-12T00:29:00.006+09:00</published><updated>2014-03-12T09:23:19.766+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#で7DSRの計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// 7DSR　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string Get7DSR(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result)
    {
        return null;
    }

    string value =(ulong.Parse(Value) % 7 == 0 ? 0 : 7 - (ulong.Parse(Value) % 7)).ToString();

    return value;
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/53095728009665481/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/7dsr.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/53095728009665481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/53095728009665481'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/7dsr.html' title='C#で7DSRの計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-3786284991962179141</id><published>2014-03-12T00:29:00.003+09:00</published><updated>2014-03-12T09:23:42.420+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#でモジュラス16の計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// モジュラス16　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string GetModulus16(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9|\-|$|:|/|･|+|A-D]+$&quot;);
    if (!result)
    {
        return null;
    }

    long digit = 0;
    for (int i = 0; i &amp;lt; Value.Length; i++)
    {
        digit += Array.IndexOf(modulus16CharList, Value[i]);
    }

    string value = modulus16CharList[(digit % 16) == 0 ? 0 : 16 - (digit % 16)].ToString();

    return value;
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/3786284991962179141/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/16.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/3786284991962179141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/3786284991962179141'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/16.html' title='C#でモジュラス16の計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-5884109903099299925</id><published>2014-03-12T00:29:00.002+09:00</published><updated>2014-03-12T09:23:59.216+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#で7DRの計算</title><content type='html'>&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// 7DR　計算
/// NW-7
/// &lt;/summary&gt;
/// &lt;param name=&quot;Value&quot; /&gt;/// &lt;returns&gt;&lt;/returns&gt;
public static string Get7DR(string Value)
{
    bool result = Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;);
    if (!result)
    {
        return null;
    }

    string value = (ulong.Parse(Value) % 7).ToString();

    return value;
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/5884109903099299925/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2014/03/7dr.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5884109903099299925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5884109903099299925'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2014/03/7dr.html' title='C#で7DRの計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-4906344959361923058</id><published>2013-07-09T23:22:00.001+09:00</published><updated>2014-03-12T09:24:16.440+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#でモジュラス43の計算</title><content type='html'>バーコードのCode39で使うチェックディジットです&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;private static char[] modulus43CharList =
{
    &#39;0&#39;,&#39;1&#39;,&#39;2&#39;,&#39;3&#39;,&#39;4&#39;,&#39;5&#39;,&#39;6&#39;,&#39;7&#39;,&#39;8&#39;,&#39;9&#39;,
    &#39;A&#39;,&#39;B&#39;,&#39;C&#39;,&#39;D&#39;,&#39;E&#39;,&#39;F&#39;,&#39;G&#39;,&#39;H&#39;,&#39;I&#39;,&#39;J&#39;,
    &#39;K&#39;,&#39;L&#39;,&#39;M&#39;,&#39;N&#39;,&#39;O&#39;,&#39;P&#39;,&#39;Q&#39;,&#39;R&#39;,&#39;S&#39;,&#39;T&#39;,
    &#39;U&#39;,&#39;V&#39;,&#39;W&#39;,&#39;X&#39;,&#39;Y&#39;,&#39;Z&#39;,&#39;-&#39;,&#39;.&#39;,&#39; &#39;,&#39;$&#39;,
    &#39;/&#39;,&#39;+&#39;,&#39;%&#39;
};

/// &lt;summary&gt;
/// モジュラス43　計算
/// CODE39
/// &lt;/summary&gt;
public static string GetModulus43(string Value)
{
    if (!Regex.IsMatch(Value, @&quot;^[A-Z|0-9|\-|.| |$|/|+|%]+$&quot;))
    {
        throw new FormatException();
    }

    long x = 0;
    for (int i = 0; i &amp;lt; Value.Length; i++)
    {
        x += Array.IndexOf(modulus43CharList, Value[i]);
    }

    return modulus43CharList[x % 43].ToString();
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/4906344959361923058/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2013/07/43.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/4906344959361923058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/4906344959361923058'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2013/07/43.html' title='C#でモジュラス43の計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-8789624919258077443</id><published>2013-07-09T23:04:00.002+09:00</published><updated>2014-03-12T09:24:28.784+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="check digit"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#でモジュラス10/ウェイト3の計算</title><content type='html'>だいぶ前に書いたバーコード作成ソフトのコードを見直してます。&lt;br /&gt;
ソースもさらしていきます&lt;br /&gt;
&lt;br /&gt;
JANコードなどで使うチェックディジットです&lt;br /&gt;
&lt;br /&gt;
Modulus10W3コード&lt;br /&gt;
&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;
/// モジュラス10/ウェイト3　計算
/// JAN8 JAN13 ISBN13 ITF NW-7
/// &lt;/summary&gt;
public static string GetModulus10Weight3(string Value)
{
    if (!Regex.IsMatch(Value, @&quot;^[0-9]+$&quot;))
    {
        throw new FormatException();
    }

    int x = 0;
    for (int i = 0; i &amp;lt; Value.Length; i++)
    {
        x += int.Parse(Value[Value.Length - 1 - i].ToString()) * ((i % 2 == 0) ? 3 : 1);
    }

    x = (10 - (x % 10)) % 10;

    return x.ToString();
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
XMLコメントが入るとおかしくなるなあ&lt;br /&gt;
タグが消えたりしてしまう　なんでだろう</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/8789624919258077443/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2013/07/103.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/8789624919258077443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/8789624919258077443'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2013/07/103.html' title='C#でモジュラス10/ウェイト3の計算'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-7910738621481701324</id><published>2013-07-02T20:38:00.002+09:00</published><updated>2013-07-02T20:38:25.387+09:00</updated><title type='text'>と思ったんですが</title><content type='html'>無償のwordpress.comだとbloggerより制限が多いですね。&lt;br /&gt;
こっちにもどします。&lt;br /&gt;
&lt;br /&gt;
名前とかデザインを修正</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/7910738621481701324/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2013/07/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/7910738621481701324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/7910738621481701324'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2013/07/blog-post.html' title='と思ったんですが'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-5308261895383048505</id><published>2013-05-29T00:00:00.000+09:00</published><updated>2013-07-05T23:27:19.077+09:00</updated><title type='text'>Seri2Key1.3.0.0　更新</title><content type='html'>Seri2Keyでエゴサーチしてみたら&lt;br /&gt;使用してくれてる方がブログに記事を書いてくれてた。&lt;br /&gt;うれしかったので書かれていた要望点を修正しました。&lt;br /&gt;・特殊コードにALT/CTRL/SHIFTキーを追加&lt;br /&gt;・改行コードが付加されていないデータでも読めるように、改行コードの設定に”なし”を追加&lt;br /&gt;・クリップボードを使用時に入力がソフトによって上手く貼り付けできなかったのを修正&lt;br /&gt;&lt;a href=&quot;http://ux.getuploader.com/tiraura01/download/5/Seri2Key1.3.0.0.zip&quot; style=&quot;-webkit-transition: all 0.1s ease-in; border: 0px; color: #0d3d9b; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; transition: all 0.1s ease-in; vertical-align: baseline;&quot; title=&quot;Seri2Key1.3.0.0&quot;&gt;ダウンロード&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #323232; font-family: Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 16px; line-height: 26px; margin-bottom: 26px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span id=&quot;more-131&quot; style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/5308261895383048505/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2013/05/seri2key1300.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5308261895383048505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5308261895383048505'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2013/05/seri2key1300.html' title='Seri2Key1.3.0.0　更新'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-8016726276179724433</id><published>2013-04-26T00:00:00.000+09:00</published><updated>2013-07-05T23:26:31.276+09:00</updated><title type='text'>VisualStudio2012</title><content type='html'>VisualStudio2010で作ったソリューションをVisualStudio2012で開いた場合、&lt;br /&gt;
今までのようにプロジェクトのアップグレードをしなくてもよくなってた。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://msdn.microsoft.com/ja-jp/library/vstudio/hh266747.aspx&quot; style=&quot;-webkit-transition: all 0.1s ease-in; border: 0px; color: #0d3d9b; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; transition: all 0.1s ease-in; vertical-align: baseline;&quot;&gt;Visual Studio 2012 の互換性&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://msdn.microsoft.com/ja-jp/library/vstudio/hh266747.aspx&quot; style=&quot;-webkit-transition: all 0.1s ease-in; border: 0px; color: #0d3d9b; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; transition: all 0.1s ease-in; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/a&gt;確認したところ2012で作業後に保存しなおしても2010で開くことができた。&lt;br /&gt;
とうぜんだけど2008のソリューションはだめでした&lt;br /&gt;
開発で使っている環境がWindows XP/7/8だったためXPに合わせて2010を使ってたけど。&lt;br /&gt;
7と8はVisualStudio2012に移行できそうでつ&lt;br /&gt;
うれしかったのでさっそく&lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/9ba50f8d-f30c-4e33-ab19-bfd9f56eb817&quot; style=&quot;-webkit-transition: all 0.1s ease-in; border: 0px; color: #0d3d9b; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; transition: all 0.1s ease-in; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;ClaudiaIDE&lt;/a&gt;を導入</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/8016726276179724433/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2013/07/visualstudio2012.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/8016726276179724433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/8016726276179724433'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2013/07/visualstudio2012.html' title='VisualStudio2012'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-23249835271301219</id><published>2013-04-20T01:20:00.001+09:00</published><updated>2013-04-20T01:21:34.912+09:00</updated><title type='text'>ブログの移行</title><content type='html'>wordpressを仕事で使いたかったので練習もかねて移行します。&lt;br /&gt;
&lt;a href=&quot;http://komozo.wordpress.com/&quot;&gt;http://komozo.wordpress.com/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
ここと同じで数年更新しないかもしれませんが。</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/23249835271301219/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2013/04/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/23249835271301219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/23249835271301219'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2013/04/blog-post.html' title='ブログの移行'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-2715541038333995324</id><published>2013-04-19T00:00:00.000+09:00</published><updated>2013-07-05T23:25:07.740+09:00</updated><title type='text'>ソフトウエア</title><content type='html'>&lt;br /&gt;
&lt;header class=&quot;entry-header&quot; style=&quot;background-color: white; border: 0px; color: #323232; font-family: Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 16px; line-height: 26px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 26px;&quot;&gt;ブログ書くネタがなかったんで以前に作ったアプリを手直しして公開&lt;/span&gt;&lt;/header&gt;&lt;br /&gt;
&lt;div class=&quot;entry-content&quot; style=&quot;background-color: white; border: 0px; color: #323232; font-family: Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 16px; line-height: 26px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; margin-bottom: 26px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
RS232Cのデータを取得してキーボード出力するソフトと、1Dバーコードの生成ツールです。&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/2715541038333995324/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2013/07/blog-post_5.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/2715541038333995324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/2715541038333995324'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2013/07/blog-post_5.html' title='ソフトウエア'/><author><name>komozo</name><uri>http://www.blogger.com/profile/05633109470034645123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-1843775691156748828</id><published>2011-06-03T00:53:00.004+09:00</published><updated>2014-03-11T12:19:53.032+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="バーコードソフト"/><title type='text'>C#でバーコード</title><content type='html'>1次元バーコードの描画処理を作ってみました。&lt;br /&gt;
バーコードの解説サイトを見ながら、&lt;br /&gt;
Code39、Code128、ISBN13、JAN13、JAN8、JapanesePostal（カスタマーバーコード）を実装。&lt;br /&gt;
&lt;br /&gt;
JapanesePostalは手持ちのバーコードリーダーで読めないため、目視によるチェック&lt;br /&gt;
自信なし。&lt;br /&gt;
&lt;br /&gt;
Code128は制御コードも入力できるようにしてみた。&lt;br /&gt;
フリーでは制御コード対応しているものが見つけれず、&lt;br /&gt;
参考にするものが無いため、うまく動いているのかわからない＞＜&lt;br /&gt;
&lt;br /&gt;
簡易的な出力ツールを作ってみました。&lt;br /&gt;
Code128で使えるコード表も置いておきます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhncsaOkibA3xJ7vk0WXAz1kzaz5XGksMnAbLiWRYh_QzNXBBN_YvLtvggF0BEMqsahBRbQMYk9l7A9-cwegFFi-7GPqpBCMIZ4HhnSSrmSyQSBxQlsns2VSIYKkjCNMTfeoeM_NOxhUCg/s1600/barcode4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhncsaOkibA3xJ7vk0WXAz1kzaz5XGksMnAbLiWRYh_QzNXBBN_YvLtvggF0BEMqsahBRbQMYk9l7A9-cwegFFi-7GPqpBCMIZ4HhnSSrmSyQSBxQlsns2VSIYKkjCNMTfeoeM_NOxhUCg/s320/barcode4.jpg&quot; height=&quot;288&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfE6keorHIH4LU2D5pwgPGVJMe_UjWWwzsbhTo6ylQ-JtDtThq9PxgFbt1Rf6bu-Ye3mC-ErInkwPsVyTaLhUurU360zHS0wKbYWW7tMKH4jVk5I8-8E7RB95cK2YQ47yc7VX1BhNPTJ0/s1600/barcode5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfE6keorHIH4LU2D5pwgPGVJMe_UjWWwzsbhTo6ylQ-JtDtThq9PxgFbt1Rf6bu-Ye3mC-ErInkwPsVyTaLhUurU360zHS0wKbYWW7tMKH4jVk5I8-8E7RB95cK2YQ47yc7VX1BhNPTJ0/s320/barcode5.jpg&quot; height=&quot;320&quot; width=&quot;148&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ux.getuploader.com/tekitou000/download/5/Barcodegen.zip&quot;&gt;ダウンロード&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
バグあったらコメントお願いします＞＜&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://komozo.blogspot.jp/p/blog-page_2.html&quot;&gt;2013/04/20追記　最新のバージョンはこちらから&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/1843775691156748828/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2011/06/c.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/1843775691156748828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/1843775691156748828'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2011/06/c.html' title='C#でバーコード'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhncsaOkibA3xJ7vk0WXAz1kzaz5XGksMnAbLiWRYh_QzNXBBN_YvLtvggF0BEMqsahBRbQMYk9l7A9-cwegFFi-7GPqpBCMIZ4HhnSSrmSyQSBxQlsns2VSIYKkjCNMTfeoeM_NOxhUCg/s72-c/barcode4.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-5252680249389798342</id><published>2011-04-12T01:37:00.002+09:00</published><updated>2013-07-05T23:43:23.919+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><title type='text'>C# 円錐形グラデーション</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;
円錐形のグラデーションの描画方法が分からなかったので、&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;
書いてみた。&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;
本当はもっと簡単な方法があるのかもしれない。&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOZaJhYg5nLTS4Qj63kNxq7y2wsS3Hx7FRO5zRo5VkT9f_R_TK2X34YQv6MfLYZKGpM35Ar8nbnDo_W-rPxA-4l528lrNuO3HKyaHOmOmEfVYDUc7jPSDaC9q7vZ8xMrD4a1pBvj5FZ4I/s1600/ConicalGradient1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOZaJhYg5nLTS4Qj63kNxq7y2wsS3Hx7FRO5zRo5VkT9f_R_TK2X34YQv6MfLYZKGpM35Ar8nbnDo_W-rPxA-4l528lrNuO3HKyaHOmOmEfVYDUc7jPSDaC9q7vZ8xMrD4a1pBvj5FZ4I/s320/ConicalGradient1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOZaJhYg5nLTS4Qj63kNxq7y2wsS3Hx7FRO5zRo5VkT9f_R_TK2X34YQv6MfLYZKGpM35Ar8nbnDo_W-rPxA-4l528lrNuO3HKyaHOmOmEfVYDUc7jPSDaC9q7vZ8xMrD4a1pBvj5FZ4I/s1600/ConicalGradient1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOZaJhYg5nLTS4Qj63kNxq7y2wsS3Hx7FRO5zRo5VkT9f_R_TK2X34YQv6MfLYZKGpM35Ar8nbnDo_W-rPxA-4l528lrNuO3HKyaHOmOmEfVYDUc7jPSDaC9q7vZ8xMrD4a1pBvj5FZ4I/s1600/ConicalGradient1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOZaJhYg5nLTS4Qj63kNxq7y2wsS3Hx7FRO5zRo5VkT9f_R_TK2X34YQv6MfLYZKGpM35Ar8nbnDo_W-rPxA-4l528lrNuO3HKyaHOmOmEfVYDUc7jPSDaC9q7vZ8xMrD4a1pBvj5FZ4I/s1600/ConicalGradient1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOZaJhYg5nLTS4Qj63kNxq7y2wsS3Hx7FRO5zRo5VkT9f_R_TK2X34YQv6MfLYZKGpM35Ar8nbnDo_W-rPxA-4l528lrNuO3HKyaHOmOmEfVYDUc7jPSDaC9q7vZ8xMrD4a1pBvj5FZ4I/s1600/ConicalGradient1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;//
// ConicalGradient  円錐形グラデーションの描画クラス
//
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

using System.Threading.Tasks;

namespace DrawTest
{
    class ConicalGradient
    {
        
        public static Bitmap GetBitmap(Color[] colorList, int width, int height)
        {
            return GetBitmap(colorList, 0, width, height, width / 2, height / 2);
        }

        public static Bitmap GetBitmap(Color[] colorList, double d, int width, int height)
        {
            return GetBitmap(colorList, d, width, height, width / 2, height / 2);
        }

        public static Bitmap GetBitmap(Color[] colorList, double d, int width, int height, int centerX, int centerY)
        {
            try
            {
                //Color配列が空の時はHueの値でも入れとく
                if (colorList == null || colorList.Length == 0)
                {
                    colorList = new Color[6];
                    colorList[0] = Color.FromArgb(255, 0, 0);
                    colorList[1] = Color.FromArgb(255, 255, 0);
                    colorList[2] = Color.FromArgb(0, 255, 0);
                    colorList[3] = Color.FromArgb(0, 255, 255);
                    colorList[4] = Color.FromArgb(0, 0, 255);
                    colorList[5] = Color.FromArgb(255, 0, 255);
                }

                Color[] colArry;
                int colLength;

                //色と色の間隔は最大でも256色なので×配列の要素数分の色を作っとく
                colArry = new Color[colorList.Length * 256];
                colLength = colArry.Length;
                Parallel.For(0, colLength, delegate(int i)
                {
                //for (int i = 0; i &amp;lt; colLength; i++)
                //{
                    colArry[i] = GetColor(colorList, ((double)i / colLength) * 360.0);
                //}
                });


                Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                int stride = bmpData.Stride;
                byte[] bmpByte = new byte[height * stride];

                const double rad = 180 / Math.PI;

                Parallel.For(0, width, delegate(int i)
                {
                //for (int i = 0; i &amp;lt; width; i++) 
                //{
                    for (int j = 0; j &amp;lt; height; j++)
                    {
                        double angle = (Math.Atan2(centerY - j, centerX - i) * rad) + 180 + d;
                        angle = (angle + 360) % 360;//0～359.99…の中に収める

                        Color col = colArry[(int)(angle * (colLength / 360.0))];

                        bmpByte[(i * 4) + (j * stride) + 3] = col.A;
                        bmpByte[(i * 4) + (j * stride) + 2] = col.R;
                        bmpByte[(i * 4) + (j * stride) + 1] = col.G;
                        bmpByte[(i * 4) + (j * stride) + 0] = col.B;
                    }
                //}
                });

                Marshal.Copy(bmpByte, 0, bmpData.Scan0, bmpByte.Length);
                bmp.UnlockBits(bmpData);

                return bmp;
            }
            catch
            {
                return null;
            }
        }

        /// &lt;summary&gt;
        /// 色の取得
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;colors&quot; /&gt;/// &lt;param name=&quot;angle&quot; /&gt;0.0～259.99...        /// &lt;returns&gt;&lt;/returns&gt;         private static Color GetColor(Color[] colors, double angle)         {             //色の初期化             int a, r, g, b,                 //色の数              length = colors.Length,               num = 0;              int d = (int)(angle / (360.0 / length));              double rest = (angle % (360.0 / length)) / (360.0 / length);               if (d + 1 &amp;lt; length) num = d + 1;              int startA = colors[d].A, endA = colors[num].A,                 startR = colors[d].R, endR = colors[num].R,                 startG = colors[d].G, endG = colors[num].G,                 startB = colors[d].B, endB = colors[num].B;              if (startA &amp;lt; endA)             {                 a = startA + (int)((endA - startA) * rest);             }             else             {                 a = startA - (int)((startA - endA) * rest);             }              if (startR &amp;lt; endR)             {                 r = startR + (int)((endR - startR) * rest);             }             else             {                 r = startR - (int)((startR - endR) * rest);             }              if (startG &amp;lt; endG)             {                 g = startG + (int)((endG - startG) * rest);             }             else             {                 g = startG - (int)((startG - endG) * rest);             }              if (startB &amp;lt; endB)             {                 b = startB + (int)((endB - startB) * rest);             }             else             {                 b = startB - (int)((startB - endB) * rest);             }              return Color.FromArgb(a, r, g, b);         }     } }  &lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgocKKl0x0LX9-XNrUXPBVXP7FQ0KaRWt4QHehpn3M60iafnhWMpOmYksBeX2NaVrr90taA89EdoMtn8WKZnRvlJAnNsumOUq6bPIgyQvDUlQBCFvP-zFws_JEEQ8yFlxhF373SM00J11Q/s1600/ConicalGradient2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt; &lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgocKKl0x0LX9-XNrUXPBVXP7FQ0KaRWt4QHehpn3M60iafnhWMpOmYksBeX2NaVrr90taA89EdoMtn8WKZnRvlJAnNsumOUq6bPIgyQvDUlQBCFvP-zFws_JEEQ8yFlxhF373SM00J11Q/s1600/ConicalGradient2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt; &lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgocKKl0x0LX9-XNrUXPBVXP7FQ0KaRWt4QHehpn3M60iafnhWMpOmYksBeX2NaVrr90taA89EdoMtn8WKZnRvlJAnNsumOUq6bPIgyQvDUlQBCFvP-zFws_JEEQ8yFlxhF373SM00J11Q/s1600/ConicalGradient2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgocKKl0x0LX9-XNrUXPBVXP7FQ0KaRWt4QHehpn3M60iafnhWMpOmYksBeX2NaVrr90taA89EdoMtn8WKZnRvlJAnNsumOUq6bPIgyQvDUlQBCFvP-zFws_JEEQ8yFlxhF373SM00J11Q/s320/ConicalGradient2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
テストに作ってみたコントロール クリックで中心が移動してドラッグで回転する感じ。  
&lt;br /&gt;
&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;using System.Drawing;
using System.Windows.Forms;
using System;
using System.Drawing.Drawing2D;
using System.Diagnostics;

namespace DrawTest
{
    class ConicalGradientView : Control
    {
        private Bitmap bmp;

        private double angle = 0;

        private Point center;
        public Point Center
        {
            get { return center; }
            set
            {
                center = value;
                Refresh();
            }
        }

        private Color[] colors = null;
        public Color[] Colors
        {
            get { return colors; }
            set
            {
                colors = value;
                Refresh();
            }
        }

        public ConicalGradientView()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            Stopwatch sw = new Stopwatch();
            sw.Start();

            bmp = ConicalGradient.GetBitmap(colors, angle, this.ClientSize.Width, this.ClientSize.Height, Center.X, Center.Y);

            Console.WriteLine(sw.Elapsed);

            if (bmp != null)
            {
                pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                pe.Graphics.FillEllipse(new TextureBrush(bmp), 0, 0, this.ClientSize.Width - 1, this.ClientSize.Height - 1);
                pe.Graphics.DrawEllipse(Pens.Black, 0, 0, this.ClientSize.Width - 1, this.ClientSize.Height - 1);

                pe.Graphics.DrawEllipse(Pens.Black, Center.X - 5, Center.Y - 5, 10, 10);
            }
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            Center = e.Location;
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (e.Button == MouseButtons.Left)
            {
                angle = (Math.Atan2(Center.X - e.X, Center.Y - e.Y) * (180 / Math.PI));

                Refresh();
            }
        }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
Conical Gradient</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/5252680249389798342/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2011/04/c.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5252680249389798342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/5252680249389798342'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2011/04/c.html' title='C# 円錐形グラデーション'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOZaJhYg5nLTS4Qj63kNxq7y2wsS3Hx7FRO5zRo5VkT9f_R_TK2X34YQv6MfLYZKGpM35Ar8nbnDo_W-rPxA-4l528lrNuO3HKyaHOmOmEfVYDUc7jPSDaC9q7vZ8xMrD4a1pBvj5FZ4I/s72-c/ConicalGradient1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-662271246520571665</id><published>2011-04-08T00:04:00.010+09:00</published><updated>2014-03-12T01:18:53.408+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><title type='text'>C# RGB ⇔ CIEXYZ ⇔ CIELAB　相互変換</title><content type='html'>RGB⇔CIEXYZ⇔CIELABの相互変換できる構造体を作成した&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;//RGBからL*a*b*へ
CIELAB Lab = new CIELAB(Color.Blue);
//L*a*b*からRGBへ
Color col = Lab.ToColor();
//RGBからCIEXYZへ
CIEXYZ xyz = new CIEXYZ(Color.Blue);
//CIEXYZからRGBへ
Color col = xyz.ToColor();
//L*a*b*からXYZへ
CIEXYZ xyz = new CIEXYZ(Lab);
//XYZからL*a*b*へ
CIELAB Lab = new CIELAB(xyz);

&lt;/pre&gt;こんなかんじで。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;//   
//　CIELAB構造体   
// Hiroaki,Komori    
//   
using System;
using System.Drawing;
 
struct CIELAB
{
  private const double Xn = 0.950456;
  private const double Yn = 1.0;
  private const double Zn = 1.088754;
 
  private double l;
  private double a;
  private double b;
 
  public double L
  {
    get { return l; }
    set { l = value; }
  }
 
  public double A
  {
    get { return a; }
    set { a = value; }
  }
 
  public double B
  {
    get { return b; }
    set { b = value; }
  }
 
 
  public CIELAB(Double _L, Double _A, Double _B)
  {
    l = _L;
    a = _A;
    b = _B;
  }
 
  public CIELAB(Color rgb)
  {
    CIELAB _lab = CIELAB.Parse(rgb);
    l = _lab.L;
    a = _lab.A;
    b = _lab.B;
  }
 
  public CIELAB(CIEXYZ xyz)
  {
    CIELAB _lab = CIELAB.Parse(xyz);
    l = _lab.L;
    a = _lab.A;
    b = _lab.B;
  }
 
  ///&lt;summary&gt;
  /// Colorへ変換
  ///&lt;/summary&gt;
  ///&lt;param name=&quot;&quot;hsv&quot;&quot;&gt;///&lt;returns&gt;&lt;/returns&gt;
  public Color ToColor()
  {
    return ToCIEXyz().ToColor();
  }
 
  ///&lt;summary&gt;
  /// CIEXyzへ変換
  ///&lt;/summary&gt;
  ///&lt;param name=&quot;&quot;hsv&quot;&quot;&gt;///&lt;returns&gt;&lt;/returns&gt;
  public CIEXYZ ToCIEXyz()
  {
    double _delta = 6.0 / 29.0;
    double _fy = (l + 16.0) / 116.0;
    double _fx = _fy + a / 500.0;
    double _fz = _fy - b / 200.0;
 
    double _x, _y, _z;
 
    if (_fx &gt; _delta)
    {
      _x = Xn * Math.Pow(_fx, 3);
    }
    else
    {
      _x = (_fx - 16.0 / 116.0) * 3 * Math.Pow(_delta, 2);
    }
 
    if (_fy &gt; _delta)
    {
      _y = Yn * Math.Pow(_fy, 3);
    }
    else
    {
      _y = (_fy - 16.0 / 116.0) * 3 * Math.Pow(_delta, 2);
    }
 
    if (_fz &gt; _delta)
    {
      _z = Zn * Math.Pow(_fz, 3);
    }
    else
    {
      _z = (_fz - 16.0 / 116.0) * 3 * Math.Pow(_delta, 2);
    }
 
    return new CIEXYZ(_x, _y, _z);
  }
 
  ///&lt;summary&gt;
  /// CIEXYZからCIELabへ変換
  ///&lt;/summary&gt;
  public static CIELAB Parse(CIEXYZ xyz)
  {
    double _l = 116.0 * Fxyz(xyz.Y / Yn) - 16;
    double _a = 500.0 * (Fxyz(xyz.X / Xn) - Fxyz(xyz.Y / Yn));
    double _b = 200.0 * (Fxyz(xyz.Y / Yn) - Fxyz(xyz.Z / Zn));
 
    CIELAB _result = new CIELAB(_l, _a, _b);
 
    return _result;
  }
 
  ///&lt;summary&gt;
  /// XYZ to L*a*b* transformation function.
  ///&lt;/summary&gt;
  private static double Fxyz(double t)
  {
    double _result;
    if (t &gt; 0.008856)
    {
      _result = Math.Pow(t, (1.0 / 3.0));
    }
    else
    {
      _result = 7.787 * t + 16.0 / 116.0;
    }
 
    return _result;
  }
 
  ///&lt;summary&gt;
  /// CIEXYZからColorへ変換
  ///&lt;/summary&gt;
  ///&lt;param name=&quot;&quot;col&quot;&quot;&gt;  ///&lt;returns&gt;&lt;/returns&gt;
  public static CIELAB Parse(Color col)
  {
    CIEXYZ _xyz = CIEXYZ.Parse(col);
    return CIELAB.Parse(_xyz);
  }
 
  ///&lt;summary&gt;
  ///文字列に変換
  ///&lt;/summary&gt;
  ///&lt;returns&gt;&lt;/returns&gt;
  public override string ToString()
  {
    string _result = string.Format(&quot;CIELab [L*={0}, a*={1}, b*={2}&quot;, l.ToString(&quot;F&quot;), a.ToString(&quot;F&quot;), b.ToString(&quot;F&quot;));
    return _result;
  }
}
 
//   
//　CIEXYZ構造体   
// Hiroaki,Komori    
//   
struct CIEXYZ
{
    private double x;
    private double y;
    private double z;

    public double X
    {
        get { return x; }
        set { x = value; }
    }

    public double Y
    {
        get { return y; }
        set { y = value; }
    }

    public double Z
    {
        get { return z; }
        set { z = value; }
    }


    public CIEXYZ(Double _X, Double _Y, Double _Z)
    {
        x = _X;
        y = _Y;
        z = _Z;
    }

    public CIEXYZ(Color rgb)
    {
        CIEXYZ _xyz = Parse(rgb);

        x = _xyz.X;
        y = _xyz.Y;
        z = _xyz.Z;
    }

    ///&lt;summary&gt;
    /// CIELabからCIEXyzへ変換
    ///&lt;/summary&gt;
    ///&lt;param name=&quot;&quot;Lab&quot;&quot;&gt;    public CIEXYZ(CIELAB Lab)
    {
        CIEXYZ _xyz = Lab.ToCIEXyz();
        x = _xyz.X;
        y = _xyz.Y;
        z = _xyz.Z;
    }

    ///&lt;summary&gt;
    /// ColorからXYZへ変換
    ///&lt;/summary&gt;
    ///&lt;param name=&quot;&quot;col&quot;&quot;&gt;    ///&lt;returns&gt;&lt;/returns&gt;
    public static CIEXYZ Parse(Color col)
    {
        double _RLinear = col.R / 255d;
        double _GLinear = col.G / 255d;
        double _BLinear = col.B / 255d;

        double _r, _g, _b, _x, _y, _z;

        if (_RLinear &gt; 0.04045)
        {
            _r = Math.Pow((_RLinear + 0.055) / (1 + 0.055), 2.2);
        }
        else
        {
            _r = (_RLinear / 12.92);
        }

        if (_GLinear &gt; 0.04045)
        {
            _g = Math.Pow((_GLinear + 0.055) / (1 + 0.055), 2.2);
        }
        else
        {
            _g = (_GLinear / 12.92);
        }

        if (_BLinear &gt; 0.04045)
        {
            _b = Math.Pow((_BLinear + 0.055) / (1 + 0.055), 2.2);
        }
        else
        {
            _b = (_BLinear / 12.92);
        }

        _x = _r * 0.4124 + _g * 0.3576 + _b * 0.1805;
        _y = _r * 0.2126 + _g * 0.7152 + _b * 0.0722;
        _z = _r * 0.0193 + _g * 0.1192 + _b * 0.9505;
        CIEXYZ _result = new CIEXYZ(_x, _y, _z);

        return _result;
    }

    ///&lt;summary&gt;
    /// Colorへ変換
    ///&lt;/summary&gt;
    ///&lt;param name=&quot;&quot;Xyz&quot;&quot;&gt;    ///&lt;returns&gt;&lt;/returns&gt;
    public Color ToColor()
    {
        double _r = 3.240479 * x - 1.53715 * y - 0.498535 * z;
        double _g = -0.969256 * x + 1.875991 * y + 0.041556 * z;
        double _b = 0.055648 * x - 0.204043 * y + 1.057311 * z;

        Color _result = Color.FromArgb(FromLinear(_r), FromLinear(_g), FromLinear(_b));
        return _result;
    }

    private static int FromLinear(double v)
    {
        int _result;

        if (v &lt;= 0.0031308)
        {
            _result = (int)(Clamp(v * 12.92) * 255.0 + 0.5);
        }
        else
        {
            _result = (int)(Clamp(1.055 * Math.Pow(v, (1.0 / 2.4)) - 0.055) * 255.0 + 0.5);
        }

        return _result;
    }

    private static double Clamp(double v)
    {
        double _result = v;

        if (v &lt; 0.0)
        {
            _result = 0.0;
        }
        else if (v &gt; 1.0)
        {
            _result = 1.0;
        }

        return _result;
    }

    public CIELAB ToCIELab()
    {
        CIELAB _result = new CIELAB(new CIEXYZ(x, y, z));
        return _result;
    }

    ///&lt;summary&gt;
    ///文字列に変換
    ///&lt;/summary&gt;
    ///&lt;returns&gt;&lt;/returns&gt;
    public override string ToString()
    {
        string _result = string.Format(&quot;CIEXyz [X={0}, Y={1}, Z={2}&quot;, x.ToString(&quot;F&quot;), y.ToString(&quot;F&quot;), z.ToString(&quot;F&quot;));
        return _result;
    }
}&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/662271246520571665/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2011/04/rgbcielab.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/662271246520571665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/662271246520571665'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2011/04/rgbcielab.html' title='C# RGB ⇔ CIEXYZ ⇔ CIELAB　相互変換'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1873827350411866323.post-9197272660173430113</id><published>2011-04-07T23:46:00.007+09:00</published><updated>2014-03-12T01:11:48.273+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><title type='text'>C# RGB ⇔ HSV　相互変換　改</title><content type='html'>RGB⇔HSVができるHSVの構造体です。&lt;br /&gt;
&lt;br /&gt;
コード&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;//RGBからHSV
//
//　HSVColor構造体
//  Hiroaki,Komori 
//
using System;
using System.Drawing;
using System.Linq;

public struct HSV
{
    private int _h;
    private int _s;
    private int _v;

    public int H
    {
        get { return _h; }
        set { _h = value; }
    }

    public int S
    {
        get { return _s; }
        set { _s = value; }
    }

    public int V
    {
        get { return _v; }
        set { _v = value; }
    }

    public HSV(int h, int s, int v)
    {
        _h = h;
        _s = s;
        _v = v;
    }

    ///&lt;summary&gt;
    /// ColorからHSV
    ///&lt;/summary&gt;
    ///&lt;param name=&quot;”rgb”&quot;&gt;    public HSV(Color rgb)
    {
        byte[] cols = new byte[] { rgb.R, rgb.G, rgb.B };
        double max = cols.Max();
        double min = cols.Min();

        //Vを求める
        _v = (int)max;

        //RGBすべてが同じ場合　HとSは0 
        if (max == min)
        {
            _h = 0;
            _s = 0;
        }
        else
        {
            //Sを求める
            _s = (int)(((max - min) * 255) / max);

            //Hを求める
            _h = 0;

            if (max == rgb.R)
            {
                _h = (int)(60 * (rgb.G - rgb.B) / (max - min));
                if (_h &lt; 0)
                {
                    _h += 360;
                }
            }
            else if (max == rgb.G)
            {
                _h = (int)(60 * (2 + (rgb.B - rgb.R) / (max - min)));
                if (_h &lt; 0)
                {
                    _h += 360;
                }
            }
            else if (max == rgb.B)
            {
                _h = (int)(60 * (4 + (rgb.R - rgb.G) / (max - min)));
                if (_h &lt; 0)
                {
                    _h += 360;
                }
            }
        }
    }

    ///&lt;summary&gt;
    /// Colorへ変換
    ///&lt;/summary&gt;
    ///&lt;param name=&quot;”hsv”&quot;&gt;///&lt;returns&gt;&lt;/returns&gt;
    public Color ToColor()
    {
        return HSV.FromRgb(_h, _s, _v);
    }

    ///&lt;summary&gt;
    /// Colorへ変換
    ///&lt;/summary&gt;
    ///&lt;param name=&quot;”hsv”&quot;&gt;///&lt;returns&gt;&lt;/returns&gt;
    public static Color FromRgb(HSV hsv)
    {
        return HSV.FromRgb(hsv.H, hsv.S, hsv.V);
    }

    ///&lt;summary&gt;
    /// Colorへ変換
    ///&lt;/summary&gt;
    ///&lt;param name=&quot;”hsv”&quot;&gt;///&lt;returns&gt;&lt;/returns&gt;
    public static Color FromRgb(int h, int s, int v)
    {
        if (h == 360)
        {
            h = 0;
        }

        int Hi = (int)(Math.Floor(h / 60d) % 6);

        int f = (int)((h / 60f) - Hi);
        int p = (int)((v / 255f) * (1 - (s / 255f)));
        int q = (int)((v / 255f) * (1 - f * (s / 255f)));
        int t = (int)((v / 255f) * (1 - (1 - f) * (s / 255f)));

        p *= 255;
        q *= 255;
        t *= 255;

        Color rgb = new Color();

        switch (Hi)
        {
            case 0:
                rgb = Color.FromArgb(v, t, p);
                break;
            case 1:
                rgb = Color.FromArgb(q, v, p);
                break;
            case 2:
                rgb = Color.FromArgb(p, v, t);
                break;
            case 3:
                rgb = Color.FromArgb(p, q, v);
                break;
            case 4:
                rgb = Color.FromArgb(t, p, v);
                break;
            case 5:
                rgb = Color.FromArgb(v, p, q);
                break;
        }

        return rgb;
    }

    ///&lt;summary&gt;
    ///文字列に変換
    ///&lt;/summary&gt;
    ///&lt;returns&gt;&lt;/returns&gt;
    public override string ToString()
    {
        string result = string.Format(&quot;HSV [H={0}, S={1}, V={2}]&quot;, _h, _s, _v);
        return result;
    }
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://komozo.blogspot.com/feeds/9197272660173430113/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://komozo.blogspot.com/2011/04/rgb-hsv.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/9197272660173430113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1873827350411866323/posts/default/9197272660173430113'/><link rel='alternate' type='text/html' href='http://komozo.blogspot.com/2011/04/rgb-hsv.html' title='C# RGB ⇔ HSV　相互変換　改'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>