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

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
IT之家
IT之家
V
V2EX
Jina AI
Jina AI
V
Visual Studio Blog
有赞技术团队
有赞技术团队
博客园 - 司徒正美
博客园 - 叶小钗
The Cloudflare Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
Google Online Security Blog
Google Online Security Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News and Events Feed by Topic
N
News and Events Feed by Topic
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
SecWiki News
SecWiki News
博客园_首页
罗磊的独立博客
量子位
Latest news
Latest news
I
Intezer
V
Vulnerabilities – Threatpost
A
Arctic Wolf
Last Week in AI
Last Week in AI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
SegmentFault 最新的问题
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News | PayPal Newsroom

博客园 - 瓶子

泛型抽象厂。模式练习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