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

推荐订阅源

WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
T
The Exploit Database - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy & Cybersecurity Law Blog
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
T
Tenable Blog
TaoSecurity Blog
TaoSecurity Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
AI
AI
P
Proofpoint News Feed
A
About on SuperTechFans
P
Privacy International News Feed
月光博客
月光博客
雷峰网
雷峰网
S
Secure Thoughts
博客园 - 叶小钗
博客园 - 聂微东
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Project Zero
Project Zero
The Cloudflare Blog
SecWiki News
SecWiki News
The Hacker News
The Hacker News
V
Vulnerabilities – Threatpost
罗磊的独立博客
A
Arctic Wolf
阮一峰的网络日志
阮一峰的网络日志
Know Your Adversary
Know Your Adversary
酷 壳 – CoolShell
酷 壳 – CoolShell
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Troy Hunt's Blog
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
小众软件
小众软件
有赞技术团队
有赞技术团队
博客园 - 司徒正美
T
Tailwind CSS Blog
量子位
C
Cybersecurity and Infrastructure Security Agency CISA
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Security @ Cisco Blogs
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
L
Lohrmann on Cybersecurity

博客园 - 瓶子

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