惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 瓶子

泛型抽象厂。模式练习1 范型与反射乱画。 小技巧:用javascript实现asp.net中ispostback功能! - 瓶子 - 博客园 给定一个集合,求出其所有子集合 把以"文本文件(制表符分割)"保存的EXCEL文件导进SQLSERVER2000的DEMO! ObjectARX 2007已经发布一个多月了.贴下载地址! sql server 2005 排序规则与大小写敏感   (sql server2005学习笔记1) HELLO MONO! 德里达逝世了! - 瓶子 - 博客园 Is there any way to get detailed error information for Win32 errors when using Platform Invoke? CBI——宇宙新的婴儿照片 Longhorn的糟糕体验! 为什么ICON类型没有EQUALS方法呢? 与音乐,,纪念Arthur Rimbaud诞辰150周年 SharpDevelop 并不RUN OUTSIDE IIS 的RUN OUTSIDE IIS 有关SQL排序规则---------即"无法解决 equal to 操作的排序规则冲突"等等的菜问题. 兰波生平 今天,终于注册了BLOG了.是菜鸟.请大家关照! 还有我的小简介
en! ~c#真的好简洁。贴段C#到VB的小典型。
瓶子 · 2004-06-10 · via 博客园 - 瓶子

早上,一来就无聊。哎。今天已经10号了。不知不觉,半年又要过去了,一天天老了。感慨得撞墙。后面的代码关键是这个小部分:
                   for(int x=0; x<8; x++, flag = !flag)
                    for(int y=0; y<8; y++, flag = !flag)
                        bitmap.SetPixel(x, y, (flag ? white : black));
用VB要用一大块,可能有好的方法,我没有想到,只用了最笨的:
             For x = 0 To 8 - 1
                    flag = Not flag
                    For y = 0 To 8 - 1
                        flag = Not flag
                        Dim tempColor As Color
                        If flag Then
                            tempColor = Color.White
                        Else
                            tempColor = Color.Black
                        End If
                        bitmap.SetPixel(x, y, tempColor)
                    Next
                Next
具体的功能函数如下:
protected static IntPtr GetHalfToneBrush()
        {
            if (_halfToneBrush == IntPtr.Zero)
            { 
                Bitmap bitmap = new Bitmap(8,8,PixelFormat.Format32bppArgb);

                Color white = Color.FromArgb(255,255,255,255);
                Color black = Color.FromArgb(255,0,0,0);

               bool flag=true;
                // Alternate black and white pixels across all lines
                for(int x=0; x<8; x++, flag = !flag)
                    for(int y=0; y<8; y++, flag = !flag)
                        bitmap.SetPixel(x, y, (flag ? white : black));

                IntPtr hBitmap = bitmap.GetHbitmap();

                Win32.LOGBRUSH brush = new Win32.LOGBRUSH();

                brush.lbStyle = (uint)Win32.BrushStyles.BS_PATTERN;
                brush.lbHatch = (uint)hBitmap;

                _halfToneBrush = Gdi32.CreateBrushIndirect(ref brush);
            }
            return _halfToneBrush;
        }
改成VB:
Protected Shared Function GetHalfToneBrush_() As IntPtr
            If _halfToneBrush.Equals(IntPtr.Zero) Then

                Dim bitmap As New bitmap(8, 8, PixelFormat.Format32bppArgb)

                Dim white As Color = Color.FromArgb(255, 255, 255, 255)
                Dim black As Color = Color.FromArgb(255, 0, 0, 0)

                Dim flag As Boolean = True

                ' Alternate black and white pixels across all lines
                Dim x As Integer
                Dim y As Integer

               For x = 0 To 8 - 1
                    flag = Not flag
                    For y = 0 To 8 - 1
                        flag = Not flag
                        Dim tempColor As Color
                        If flag Then
                            tempColor = Color.White
                        Else
                            tempColor = Color.Black
                        End If
                        bitmap.SetPixel(x, y, tempColor)
                    Next
                Next
                Dim hBitmap As IntPtr = bitmap.GetHbitmap()
                Dim brush As Win32.LOGBRUSH = New Win32.LOGBRUSH
                brush.lbStyle = Convert.ToUInt32(Win32.BrushStyles.BS_PATTERN)
                brush.lbHatch = Convert.ToUInt32(hBitmap)
             _halfToneBrush = Gdi32.CreateBrushIndirect(brush)
            End If
            Return _halfToneBrush
        End Function 'GetHalfToneBrush