c#中vba textframe2thumb12.ico 是什么意思???

利用C#转换图片格式,还可转换为ico
利用C#转换图片格式,还可转换为ico
  注意:转换为ICO后效果不好.
  源代码:
  using S
  using System.Collections.G
  using System.T
  using System.D
  using System.Drawing.I
  using System.IO;
  namespace paomiangege
  public class ImageConvert
  private int ICON_W = 64;
  private int ICON_H = 64;
  public ImageConvert()
  //fileinpath,origaly picture file path,fileoutpath save filepath,index the ImageFormat you want to convert to
  public string Convert(string fileinpath, string fileoutpath, string index)
  Bitmap bitmap = new Bitmap(fileinpath);
  index = index.ToLower();
  switch (index)
  case "jpg":& bitmap.Save(fileoutpath, ImageFormat.Jpeg);
  case "jpeg": bitmap.Save(fileoutpath, ImageFormat.Jpeg);
  case "bmp":& bitmap.Save(fileoutpath, ImageFormat.Bmp);
  case "png": bitmap.Save(fileoutpath, ImageFormat.Png);
  case "emf": bitmap.Save(fileoutpath, ImageFormat.Emf);
  case "gif": bitmap.Save(fileoutpath, ImageFormat.Gif);
  case "wmf": bitmap.Save(fileoutpath, ImageFormat.Wmf);
  case "exif": bitmap.Save(fileoutpath, ImageFormat.Exif);
  case "tiff":
  Stream stream = File.Create(fileoutpath);
  bitmap.Save(stream, ImageFormat.Tiff);
  stream.Close();
  case "ico":
  Stream stream = File.Create(fileoutpath);
  ico = BitmapToIcon(bitmap, false);
  ico.Save(stream);&&&&&& //&& save the icon
  stream.Close();
  default: return "Error!";
  return "Success!";
  catch(Exception ex)
  return ex.M
  public string Convert(string fileinpath, string fileoutpath, string index,int width,int height)
  if (width &= 0 || height &= 0)
  return "error!size illegal!";
  Bitmap mybitmap = new Bitmap(fileinpath);
  Bitmap bitmap = new Bitmap(mybitmap, width, height);
  index = index.ToLower();
  switch (index)
  case "jpg": bitmap.Save(fileoutpath, ImageFormat.Jpeg);
  case "jpeg": bitmap.Save(fileoutpath, ImageFormat.Jpeg);
  case "bmp": bitmap.Save(fileoutpath, ImageFormat.Bmp);
  case "png": bitmap.Save(fileoutpath, ImageFormat.Png);
  case "emf": bitmap.Save(fileoutpath, ImageFormat.Emf);
  case "gif": bitmap.Save(fileoutpath, ImageFormat.Gif);
  case "wmf": bitmap.Save(fileoutpath, ImageFormat.Wmf);
  case "exif": bitmap.Save(fileoutpath, ImageFormat.Exif);
  case "tiff":
  Stream stream = File.Create(fileoutpath);
  bitmap.Save(stream, ImageFormat.Tiff);
  stream.Close();
  case "ico":
  if (height & 256 || width & 256)//ico maxsize 256*256
  return "Error!Size illegal!";
  ICON_H =
  ICON_W =
  Stream stream = File.Create(fileoutpath);
  ico = BitmapToIcon(mybitmap, true);
  ico.Save(stream);&&&&&& //&& save the icon
  stream.Close();
  default: return "Error!";
  return "Success!";
  catch (Exception ex)
  return ex.M
  private Icon BitmapToIcon(Bitmap obm, bool preserve)
  // if not preserving aspect
  if (!preserve)&&&&&&& // if not preserving aspect
  bm = new Bitmap(obm, ICON_W, ICON_H);& //&& rescale from original bitmap
  // if preserving aspect drop excess significance in least significant direction
  else&&&&&&&&& // if preserving aspect
  Rectangle rc = new Rectangle(0, 0, ICON_W, ICON_H);
  if (obm.Width &= obm.Height)&& //&& if width least significant
  {&&&&&&&&& //&&&& rescale with width based on max icon height
  bm = new Bitmap(obm, (ICON_H * obm.Width) / obm.Height, ICON_H);
  rc.X = (bm.Width - ICON_W) / 2;& //&&&& chop off excess width significance
  if (rc.X & 0) rc.X = 0;
  else&&&&&&&& //&& if height least significant
  {&&&&&&&&& //&&&& rescale with height based on max icon width
  bm = new Bitmap(obm, ICON_W, (ICON_W * obm.Height) / obm.Width);
  rc.Y = (bm.Height - ICON_H) / 2; //&&&& chop off excess height significance
  if (rc.Y & 0) rc.Y = 0;
  bm = bm.Clone(rc, bm.PixelFormat);& //&& bitmap for icon rectangle
  // create icon from bitmap
  Icon icon = Icon.FromHandle(bm.GetHicon()); // create icon from bitmap
  bm.Dispose();&&&&&&& // dispose of bitmap
  &&&&&&& // return icon
H3C认证Java认证Oracle认证
基础英语软考英语项目管理英语职场英语
.NETPowerBuilderWeb开发游戏开发Perl
二级模拟试题一级模拟试题一级考试经验四级考试资料
软件测试软件外包系统分析与建模敏捷开发
法律法规历年试题软考英语网络管理员系统架构设计师信息系统监理师
高级通信工程师考试大纲设备环境综合能力
路由技术网络存储无线网络网络设备
CPMP考试prince2认证项目范围管理项目配置管理项目管理案例项目经理项目干系人管理
职称考试题目
招生信息考研政治
网络安全安全设置工具使用手机安全
生物识别传感器物联网传输层物联网前沿技术物联网案例分析
Java核心技术J2ME教程
Linux系统管理Linux编程Linux安全AIX教程
Windows系统管理Windows教程Windows网络管理Windows故障
数据库开发Sybase数据库Informix数据库
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&币圈的ICO是什么意思?谈谈最近大热的ICO到底是什么
我的图书馆
币圈的ICO是什么意思?谈谈最近大热的ICO到底是什么
&   s(Initial Coin Offerings)是一种投资加密货币项目的方式,十分受欢迎。通常,一些全新的加密货币项目会通过售卖部分平台代币,而这些代币的早期持有者和爱好者有朝一日可以将代币换成钱。ICOs是加密货币项目创始人为平台运作募集资金的最好方式,大部分ICOs都以或其竞争币的形式募资。
  ICO的发起时间通常在项目完成之前,募集的资金用于创始团队的开发工作,帮助项目顺利发布。对于某些大型项目来说,部分在ICO获得的资金会由基金会接管,支持项目的不断发展。ICO代表了加密货币代币的初始分配模式,在PoS共识算法中比较常见。
  ICO参与者有助于项目的成功。他们可以帮忙进行宣传,组建更大的社区,让更多的人认识这个新项目。他们在进行代币交易的同时,还能为代币提供早期的流动性。当然了,ICO参与者是受潜在利益驱动的,他们期望项目发布之后,代币价格会高于ICO期间的价格。
  ICOs和IPOs一样吗?
  ICOs和首次公开募股(IPOs)[1]相比,两者确实有部分共同点。两者都是通过售卖股本来募集资金的,双方的投资者也都是受潜在利益驱使,权衡项目的潜力和风险。
  但两者之间存在着很大区别。ICOs的支持者基本上是一些早期的爱好者而不是专业的投资者。ICOs和kickstarter[2]类似,只不过支持者在项目中持有股本。ICOs不受监管,也不用去任何政府机构登记注册,因此,除了项目平台本身的规则之外,投资者几乎不受到保护。
  如今大部分ICOs都是打着“软件预售代币”的旗号来推广的,就像一些新游戏的内测一样。为了避免不必要的法律问题,大部分ICOs都采用“众售”或者“募捐”一类的名字。大部分ICOs还会发表免责声明,提前告知参与者这并不是一次证券销售。而至于全球司法机关是否能将其与证券销售区分开来,还是未知数。因为迄今为止,有关ICOs的案件尚未出现在法庭上。
  今年6月,政府机关首次注意到了ICOs项目——DAO。DAO是建立在以太坊智能合约上的众筹项目,但发布不久后就遭到黑客攻击。据说,美国证券交易委员会(SEC)正在调查DAO。
  ICO的历史
  史上首个明文记载的ICOs项目是万事达币(MSC),它是在Bitcointalk论坛上发起众筹的。万事达币是建立在比特币区块链上的一种传输协议,能够提供比特币协议层不能提供的功能。万事达币ICO发布于2013年6月,每个人都能通过给Exodus地址发送比特币来购买MSC,共募集了5000多个比特币(100MSC/BTC)。
  接着,Bitcointalk论坛上出现了第二个加密货币ICO项目——未来币(NXT),募集了21个比特币(当时约为6000美金)。NXT基于全新编写的加密货币代码(不是比特币初始代码的分支),并且是首个完全使用PoS的系统。当时该项目对ICO投资者来说是很成功的,全盛时期NXT的市值更是超过了1亿美元(现在只有1000万美元)。NXT也因此成为了投资者眼中最成功的ICOs。
  自从见证了NXT的成功之后,2013年底到2014年初涌现了大量的ICOs。更巧的是,当时正是比特币价格上涨幅度最大的时候。很不幸,大部分ICOs都因过度炒作或者诈骗而宣告失败。不过,那段时间的确见证了几个成功的ICOs,比如说以太坊。
  如今,以太坊成为了最大的ICOs项目之一,募集资金超过1800万美元,市值也达到了10亿美元。
  以太坊项目The DAO创建了一个智能合约,可以接受以太币投资,将投资所得用于资助加密货币项目,其运作模式和传统风投公司十分类似。至于投资选择则是由代币持有者投票决定的。从严格意义上讲,DAO并不是ICO,因为募集的资金只是存在了智能合约上,理论上这些资金是可以返还给投资者的。今年6月,攻击者利用DAO智能合约漏洞盗取了所有项目资金。
  ICOs的发展
  ICOs处于募捐和投资之间。由于该行业不断出现骗局,社区也因此发展出了大量的规则。分布式应用众筹平台Koinify(现已倒闭)就曾承诺会在发布项目之前先进行彻底的调查,并且在清楚了解某项目开发团队的目标之后才会为其转移资金。部分社区成员也曾提议使用多重签名(multi-signature)钱包来保证ICOs的安全。
  有些ICOs使用公开的比特币地址来募资,难免有损隐私性,但却有助于社区共同监督ICO的进度。
  部分ICOs采用现有的加密货币协议来创建代币。这样有助于简化代币创造的过程。未来币、合约币(Counterparty)、比特股(Bitshares)和万事达币都是按照这个方法进行ICO的。最近发布的Waves也是一个代币平台,ICO期间募集了1600多万美元。
  一些比较有名的加密货币都是靠ICO发展的,包括未来币、万事达币、比特股、以太坊、Maidsafecoin、新经币(NEM)、Synereo、公证通(Factom)、DigixDAO、Lisk和Waves。
  如何运作?
  通常,ICOs都是现在各个加密货币论坛上发布的,特别是Bitcointalk。官方帖子中会附上项目的关键信息,比如说白皮书、项目目标、ICO时间、项目发展策略、开发团队(团队等)、项目的特色以及其它相关的ICO细节。
  资金都是以比特币的方式募集的,具体有两种方法。第一种是使用一个全球通用的地址,参与者只要将比特币从自己的地址发送到ICO公共地址就可以了。第二种是为每位参与者都提供专属的比特币地址。最终所有的资金都会转向一个多重签名地址进行公示。
  不同项目的ICO细节也不同。不过至少包含了几周的募资时间,尽可能多募集点资金。有些ICOs募集的资金会超过目标金额。小部分代币将用于早期的推广奖励,比如说论坛签名、社交媒体、业务通讯等等。
  一旦ICO完成,项目正式发布之后,各个加密货币交易所会上线ICO代币。目前最大的交易所是Poloniex。代币价格会因加密货币市场行情、有关项目进展的和项目的新增特点而波动。
  注释 (? returns to text)
  首次公开募股(Initial Public Offerings,简称IPO):是指一家企业或公司 (股份有限公司)第一次将它的股份向公众出售(首次公开发行,指股份公司首次向社会公众公开招股的发行方式)。?
  Kickstarter是一间商业金融公司,它通过该网站进行公众集资以提供人们进行创意项目的筹集资金。只是考虑到众筹平台的特性,规定人们不能通过Kickstarter作为投资项目来赚钱,也就是说被投资方不可能回报金钱。因而他们以返还实物奖励(但可以标价)或者独一无二的经验给资助者来回馈,像一本写着感谢的笔记、定制的T恤、与作家共进晚餐,或者一个新产品的最初体验。?
TA的最新馆藏2017年3月 .NET技术大版内专家分月排行榜第三2017年2月 .NET技术大版内专家分月排行榜第三2016年9月 .NET技术大版内专家分月排行榜第三2016年8月 .NET技术大版内专家分月排行榜第三2016年7月 .NET技术大版内专家分月排行榜第三2016年3月 .NET技术大版内专家分月排行榜第三2016年1月 .NET技术大版内专家分月排行榜第三2015年12月 .NET技术大版内专家分月排行榜第三2015年11月 .NET技术大版内专家分月排行榜第三
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。6836人阅读
.NET(88)
文件(12)
图形(29)
。NET 本身提供的ICON的操作实在太郁闷了。自己写了个ICON的类。ICON其实是255*255以下的BMP图形的集合。 只是很少地方与BMP不同。
&&&&public&class&IconDir
&&&&&&&&private&ushort&_IdReserved&=&0;
&&&&&&&&private&ushort&_IdType&=&1;
&&&&&&&&private&ushort&_IdCount&=&1;
&&&&&&&&private&IList&IconDirentry&&_Identries&=&new&List&IconDirentry&();
&&&&&&&&public&IconDir()
&&&&&&&&public&IconDir(string&IconFile)
&&&&&&&&&&&&System.IO.FileStream&_FileStream&=&new&System.IO.FileStream(IconFile,System.IO.FileMode.Open);
&&&&&&&&&&&&byte[]&IconData&=&new&byte[_FileStream.Length];
&&&&&&&&&&&&_FileStream.Read(IconData,&0,&IconData.Length);
&&&&&&&&&&&&_FileStream.Close();
&&&&&&&&&&&&LoadData(IconData);
&&&&&&&&private&void&LoadData(byte[]&IconData)
&&&&&&&&&&&&_IdReserved&=&BitConverter.ToUInt16(IconData,&0);
&&&&&&&&&&&&_IdType&=&BitConverter.ToUInt16(IconData,&2);
&&&&&&&&&&&&_IdCount&=&BitConverter.ToUInt16(IconData,&4);
&&&&&&&&&&&&if&(_IdType&!=&1&||&_IdReserved&!=&0)&return;
&&&&&&&&&&&&int&ReadIndex=6;
&&&&&&&&&&&&for&(ushort&i&=&0;&i&!=&_IdC&i++)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&_Identries.Add(new&IconDirentry(IconData,&ref&ReadIndex));
&&&&&&&&&&&&}
&&&&&&&&&&&
&&&&&&&&public&void&SaveData(string&FileName)
&&&&&&&&&&&&if&(ImageCount&==&0)&return;
&&&&&&&&&&&&System.IO.FileStream&_FileStream&=&new&System.IO.FileStream(FileName,&System.IO.FileMode.Create);
&&&&&&&&&&&&byte[]&Temp&=&BitConverter.GetBytes(_IdReserved);
&&&&&&&&&&&&_FileStream.Write(Temp,&0,&Temp.Length);
&&&&&&&&&&&&Temp&=&BitConverter.GetBytes(_IdType);
&&&&&&&&&&&&_FileStream.Write(Temp,&0,&Temp.Length);
&&&&&&&&&&&&Temp&=&BitConverter.GetBytes((ushort)ImageCount);
&&&&&&&&&&&&_FileStream.Write(Temp,&0,&Temp.Length);
&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ImageC&i++)
&&&&&&&&&&&&{&&&&&&&&&
&&&&&&&&&&&&&&&&_FileStream.WriteByte(_Identries[i].Width);
&&&&&&&&&&&&&&&&_FileStream.WriteByte(_Identries[i].Height);
&&&&&&&&&&&&&&&&_FileStream.WriteByte(_Identries[i].ColorCount);
&&&&&&&&&&&&&&&&_FileStream.WriteByte(_Identries[i].Breserved);
&&&&&&&&&&&&&&&&Temp&=&BitConverter.GetBytes(_Identries[i].Planes);
&&&&&&&&&&&&&&&&_FileStream.Write(Temp,&0,&Temp.Length);
&&&&&&&&&&&&&&&&Temp&=&BitConverter.GetBytes(_Identries[i].Bitcount);
&&&&&&&&&&&&&&&&_FileStream.Write(Temp,&0,&Temp.Length);
&&&&&&&&&&&&&&&&Temp&=&BitConverter.GetBytes(_Identries[i].ImageSize);
&&&&&&&&&&&&&&&&_FileStream.Write(Temp,&0,&Temp.Length);
&&&&&&&&&&&&&&&&Temp&=&BitConverter.GetBytes(_Identries[i].ImageRVA);
&&&&&&&&&&&&&&&&_FileStream.Write(Temp,&0,&Temp.Length);
&&&&&&&&&&&&}
&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ImageC&i++)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&_FileStream.Write(_Identries[i].ImageData,&0,&_Identries[i].ImageData.Length);&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&&&&&&&&&_FileStream.Close();
&&&&&&&&public&Bitmap&GetImage(int&Index)
&&&&&&&&&&&&int&ReadIndex&=&0;
&&&&&&&&&&&&BitmapInfo&MyBitmap&=&new&BitmapInfo(_Identries[Index].ImageData,&ref&ReadIndex);
&&&&&&&&&&&&return&MyBitmap.IconB
&&&&&&&&public&void&AddImage(Image&SetBitmap,Rectangle&SetRectangle)
&&&&&&&&&&&&if&(SetRectangle.Width&&&255&||&SetRectangle.Height&&&255)&return;
&&&&&&&&&&&&
&&&&&&&&&&
&&&&&&&&&&&&Bitmap&IconBitmap&=&new&Bitmap(SetRectangle.Width,&SetRectangle.Height);
&&&&&&&&&&&&Graphics&g&=&Graphics.FromImage(IconBitmap);
&&&&&&&&&&&&g.DrawImage(SetBitmap,&new&Rectangle(0,&0,&IconBitmap.Width,&IconBitmap.Height),&SetRectangle,&GraphicsUnit.Pixel);
&&&&&&&&&&&&g.Dispose();
&&&&&&&&&&&&System.IO.MemoryStream&BmpMemory&=&new&System.IO.MemoryStream();
&&&&&&&&&&&&IconBitmap.Save(BmpMemory,&System.Drawing.Imaging.ImageFormat.Bmp);
&&&&&&&&&&&&IconDirentry&NewIconDirentry&=&new&IconDirentry();
&&&&&&&&&&&&BmpMemory.Position&=&14;&&&&&&&&
&&&&&&&&&&&&NewIconDirentry.ImageData&=&new&byte[BmpMemory.Length&-&14&+&128];
&&&&&&&&&&&&BmpMemory.Read(NewIconDirentry.ImageData,&0,&NewIconDirentry.ImageData.Length);
&&&&&&&&&&&&NewIconDirentry.Width&=&(byte)SetRectangle.W
&&&&&&&&&&&&NewIconDirentry.Height&=&(byte)SetRectangle.H
&&&&&&&&&&&&
&&&&&&&&&&&&byte[]&Height&=&BitConverter.GetBytes((uint)NewIconDirentry.Height&*&2);
&&&&&&&&&&&&NewIconDirentry.ImageData[8]&=&Height[0];
&&&&&&&&&&&&NewIconDirentry.ImageData[9]&=&Height[1];
&&&&&&&&&&&&NewIconDirentry.ImageData[10]&=&Height[2];
&&&&&&&&&&&&NewIconDirentry.ImageData[11]&=&Height[3];
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&NewIconDirentry.ImageSize&=&(uint)NewIconDirentry.ImageData.L
&&&&&&&&&&&&_Identries.Add(NewIconDirentry);
&&&&&&&&&&&&uint&RvaIndex&=&6&+&(uint)(_Identries.Count&*&16);
&&&&&&&&&&&&for&(int&i&=&0;&i&!=&_Identries.C&i++)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&_Identries[i].ImageRVA&=&RvaI
&&&&&&&&&&&&&&&&RvaIndex&+=&_Identries[i].ImageS
&&&&&&&&&&&&}
&&&&&&&&public&void&DelImage(int&Index)
&&&&&&&&&&&
&&&&&&&&&&&&_Identries.RemoveAt(Index);
&&&&&&&&&&&&uint&RvaIndex&=&6&+&(uint)(_Identries.Count&*&16);
&&&&&&&&&&&&for&(int&i&=&0;&i&!=&_Identries.C&i++)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&_Identries[i].ImageRVA&=&RvaI
&&&&&&&&&&&&&&&&RvaIndex&+=&_Identries[i].ImageS
&&&&&&&&&&&&}
&&&&&&&&public&int&ImageCount&{&get&{&return&_Identries.C&}&}
&&&&&&&&private&class&IconDirentry
&&&&&&&&&&&&public&IconDirentry()
&&&&&&&&&&&&{
&&&&&&&&&&&&}
&&&&&&&&&&&&public&IconDirentry(byte[]&IconDate,&ref&int&ReadIndex)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&bWidth&=&IconDate[ReadIndex];
&&&&&&&&&&&&&&&&ReadIndex++;
&&&&&&&&&&&&&&&&bHeight&=&IconDate[ReadIndex];
&&&&&&&&&&&&&&&&ReadIndex++;
&&&&&&&&&&&&&&&&bColorCount&=&IconDate[ReadIndex];
&&&&&&&&&&&&&&&&ReadIndex++;
&&&&&&&&&&&&&&&&breserved&=&IconDate[ReadIndex];
&&&&&&&&&&&&&&&&ReadIndex++;
&&&&&&&&&&&&&&&&wplanes&=&BitConverter.ToUInt16(IconDate,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&2;
&&&&&&&&&&&&&&&&wbitcount&=&BitConverter.ToUInt16(IconDate,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&2;
&&&&&&&&&&&&&&&&dwbytesinres&=&BitConverter.ToUInt32(IconDate,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&dwimageoffset&=&BitConverter.ToUInt32(IconDate,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&System.IO.MemoryStream&MemoryData&=&new&System.IO.MemoryStream(IconDate,&(int)dwimageoffset,&(int)dwbytesinres);
&&&&&&&&&&&&&&&&_ImageData&=&new&byte[dwbytesinres];
&&&&&&&&&&&&&&&&MemoryData.Read(_ImageData,&0,&_ImageData.Length);
&&&&&&&&&&&&}
&&&&&&&&&&&&private&byte&bWidth&=&16;
&&&&&&&&&&&&private&byte&bHeight&=&16;
&&&&&&&&&&&&private&byte&bColorCount&=&0;&&&&&&&
&&&&&&&&&&&&private&byte&breserved&=&0;&&&&&&&&
&&&&&&&&&&&&private&ushort&wplanes&=&1;&&&&&&&&&
&&&&&&&&&&&&private&ushort&wbitcount&=&32;&&&&&&
&&&&&&&&&&&&private&uint&dwbytesinres&=&0;
&&&&&&&&&&&&private&uint&dwimageoffset&=&0;&&&&&&&&&
&&&&&&&&&&&&private&byte[]&_ImageD
&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&byte&Width&{&get&{&return&bW&}&set&{&bWidth&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&byte&Height&{&get&{&return&bH&}&set&{&bHeight&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&byte&ColorCount&{&get&{&return&bColorC&}&set&{&bColorCount&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&byte&Breserved&{&get&{&return&&}&set&{&breserved&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&ushort&Planes&{&get&{&return&&}&set&{&wplanes&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&ushort&Bitcount&{&get&{&return&&}&set&{&wbitcount&=&&}&}&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&ImageSize&{&get&{&return&&}&set&{&dwbytesinres&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&ImageRVA&{&get&{&return&&}&set&{&dwimageoffset&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&byte[]&ImageData&{&get&{&return&_ImageD&}&set&{&_ImageData&=&&}&}
&&&&&&&&private&class&BitmapInfo
&&&&&&&&&&&&private&uint&biSize&=&40;&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&private&uint&biW&
&&&&&&&&&&&&private&uint&biH&&&&&&&&&&&&&&&
&&&&&&&&&&&&private&ushort&biPlanes&=&1;&&&&&&&&&&&&&&&&
&&&&&&&&&&&&private&ushort&biBitC&&&&&&&&&&&&&&&&
&&&&&&&&&&&&private&uint&biCompression&=&0;&&&&&&&
&&&&&&&&&&&&private&uint&biSizeI&&&&&&&&&&
&&&&&&&&&&&&private&uint&biXPelsPerM&&&&
&&&&&&&&&&&&private&uint&biYPelsPerM&&&
&&&&&&&&&&&&private&uint&biClrU&&&&&&&&&
&&&&&&&&&&&&private&uint&biClrI
&&&&&&&&&&&&public&IList&Color&&ColorTable&=&new&List&Color&();
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&InfoSize&{&get&{&return&biS&}&set&{&biSize&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&Width&{&get&{&return&biW&}&set&{&biWidth&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&Height&{&get&{&return&biH&}&set&{&biHeight&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&ushort&Planes&{&get&{&return&biP&}&set&{&biPlanes&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&ushort&BitCount&{&get&{&return&biBitC&}&set&{&biBitCount&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&Compression&{&get&{&return&biC&}&set&{&biCompression&=&&}&}
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&SizeImage&{&get&{&return&biSizeI&}&set&{&biSizeImage&=&&}&}&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&XPelsPerMeter&{&get&{&return&biXPelsPerM&}&set&{&biXPelsPerMeter&=&&}&}&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&YPelsPerMeter&{&get&{&return&biYPelsPerM&}&set&{&biYPelsPerMeter&=&&}&}&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&ClrUsed&{&get&{&return&biClrU&}&set&{&biClrUsed&=&&}&}&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&uint&ClrImportant&{&get&{&return&biClrI&}&set&{&biClrImportant&=&&}&}
&&&&&&&&&&&&private&Bitmap&_IconBitM
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public&Bitmap&IconBmp&{&get&{&return&_IconBitM&}&set&{&_IconBitMap&=&&}&}
&&&&&&&&&&&&public&BitmapInfo(byte[]&ImageData,&ref&int&ReadIndex)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&#region&基本数据
&&&&&&&&&&&&&&&&biSize&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&if&(biSize&!=&40)&return;
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biWidth&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biHeight&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biPlanes&=&BitConverter.ToUInt16(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&2;
&&&&&&&&&&&&&&&&biBitCount&=&BitConverter.ToUInt16(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&2;
&&&&&&&&&&&&&&&&biCompression&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biSizeImage&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biXPelsPerMeter&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biYPelsPerMeter&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biClrUsed&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&biClrImportant&=&BitConverter.ToUInt32(ImageData,&ReadIndex);
&&&&&&&&&&&&&&&&ReadIndex&+=&4;
&&&&&&&&&&&&&&&&#endregion
&&&&&&&&&&&&&&&&int&ColorCount&=&RgbCount();
&&&&&&&&&&&&&&&&if&(ColorCount&==&-1)&return;
&&&&&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ColorC&i++)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&byte&Blue&=&ImageData[ReadIndex];
&&&&&&&&&&&&&&&&&&&&byte&Green&=&ImageData[ReadIndex&+&1];
&&&&&&&&&&&&&&&&&&&&byte&Red&=&ImageData[ReadIndex&+&2];
&&&&&&&&&&&&&&&&&&&&byte&Reserved&=&ImageData[ReadIndex&+&3];
&&&&&&&&&&&&&&&&&&&&ColorTable.Add(Color.FromArgb((int)Reserved,&(int)Red,&(int)Green,&(int)Blue));
&&&&&&&&&&&&&&&&&&&&ReadIndex+=4;&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&int&Size&=&(int)(biBitCount&*&biWidth)&/&8;&&&&&&&
&&&&&&&&&&&&&&&&if&((double)Size&&&biBitCount&*&biWidth&/&8)&Size++;&&&&&&&
&&&&&&&&&&&&&&&&if&(Size&&&4)&Size&=&4;
&&&&&&&&&&&&&&&&byte[]&WidthByte&=&new&byte[Size];
&&&&&&&&&&&&&&&&_IconBitMap&=&new&Bitmap((int)biWidth,&(int)(biHeight&/&2));
&&&&&&&&&&&&&&&&for&(int&i&=&(int)(biHeight&/&2);&i&!=&0;&i--)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&for(int&z=0;z!=Sz++)
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&WidthByte[z]&=&ImageData[ReadIndex&+&z];&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&ReadIndex+=S
&&&&&&&&&&&&&&&&&&&&IconSet(_IconBitMap,&i&-&1,&WidthByte);&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&int&MaskSize&=&(int)(biWidth&/&8);
&&&&&&&&&&&&&&&&if&((double)MaskSize&&&biWidth&/&8)&MaskSize++;&&&&&&&
&&&&&&&&&&&&&&&&if&(MaskSize&&&4)&MaskSize&=&4;
&&&&&&&&&&&&&&&&byte[]&MashByte&=&new&byte[MaskSize];
&&&&&&&&&&&&&&&&for&(int&i&=&(int)(biHeight&/&2);&i&!=&0;&i--)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&for&(int&z&=&0;&z&!=&MaskS&z++)
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&MashByte[z]&=&ImageData[ReadIndex&+&z];
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&ReadIndex&+=&MaskS
&&&&&&&&&&&&&&&&&&&&IconMask(_IconBitMap,&i&-&1,&MashByte);
&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&&&&&&&&&private&int&RgbCount()
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&switch&(biBitCount)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&case&1:
&&&&&&&&&&&&&&&&&&&&&&&&return&2;
&&&&&&&&&&&&&&&&&&&&case&4:
&&&&&&&&&&&&&&&&&&&&&&&&return&16;
&&&&&&&&&&&&&&&&&&&&case&8:
&&&&&&&&&&&&&&&&&&&&&&&&return&256;
&&&&&&&&&&&&&&&&&&&&case&24:
&&&&&&&&&&&&&&&&&&&&&&&&return&0;
&&&&&&&&&&&&&&&&&&&&case&32:
&&&&&&&&&&&&&&&&&&&&&&&&return&0;
&&&&&&&&&&&&&&&&&&&&default:
&&&&&&&&&&&&&&&&&&&&&&&&return&-1;
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&&&&&private&void&IconSet(Bitmap&IconImage,int&RowIndex,byte[]&ImageByte)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&int&Index&=&0;
&&&&&&&&&&&&&&&&switch&(biBitCount)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&case&1:
&&&&&&&&&&&&&&&&&&&&&&&&#region&一次读8位&绘制8个点
&&&&&&&&&&&&&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ImageByte.L&i++)
&&&&&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&System.Collections.BitArray&MyArray&=new&System.Collections.BitArray(new&byte[]{ImageByte[i]});
&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(&Index,RowIndex,&ColorTable[GetBitNumb(MyArray[7])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(&Index,RowIndex,&ColorTable[GetBitNumb(MyArray[6])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[GetBitNumb(MyArray[5])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[GetBitNumb(MyArray[4])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[GetBitNumb(MyArray[3])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[GetBitNumb(MyArray[2])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(&Index,RowIndex,&ColorTable[GetBitNumb(MyArray[1])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[GetBitNumb(MyArray[0])]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&#endregion
&&&&&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&&&&&case&4:
&&&&&&&&&&&&&&&&&&&&&&&&#region&一次读8位&绘制2个点
&&&&&&&&&&&&&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ImageByte.L&i++)
&&&&&&&&&&&&&&&&&&&&&&&&{&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&int&High=ImageByte[i]&&4;&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&int&Low=ImageByte[i]-(High&&4);&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[High]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[Low]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&#endregion
&&&&&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&&&&&case&8:
&&&&&&&&&&&&&&&&&&&&&&&&#region&一次读8位&绘制一个点
&&&&&&&&&&&&&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ImageByte.L&i++)
&&&&&&&&&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(Index&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(Index,&RowIndex,&ColorTable[ImageByte[i]]);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index++;&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&#endregion
&&&&&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&&&&&case&24:
&&&&&&&&&&&&&&&&&&&&&&&&#region&一次读24位&绘制一个点
&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ImageByte.Length&/&3;&i++)
&&&&&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(i&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(i,&RowIndex,&Color.FromArgb(ImageByte[Index&+&2],&ImageByte[Index&+&1],&ImageByte[Index]));
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index&+=&3;
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&#endregion
&&&&&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&&&&&case&32:
&&&&&&&&&&&&&&&&&&&&&&&&#region&一次读32位&绘制一个点
&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&for&(int&i&=&0;&i&!=&ImageByte.Length/4;&i++)
&&&&&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(i&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&IconImage.SetPixel(i,&RowIndex,&Color.FromArgb(ImageByte[Index&+&2],&ImageByte[Index&+&1],&ImageByte[Index]));
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Index+=4;
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&#endregion
&&&&&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&&&&&default:
&&&&&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&&&&&&&&&private&void&IconMask(Bitmap&IconImage,&int&RowIndex,&byte[]&MaskByte)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&System.Collections.BitArray&Set&=&new&System.Collections.BitArray(MaskByte);
&&&&&&&&&&&&&&&&int&ReadIndex=0;
&&&&&&&&&&&&&&&&for&(int&i&=&Set.C&i&!=0&;&i--)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&if&(ReadIndex&&=&IconImage.Width)&return;
&&&&&&&&&&&&&&&&&&&&Color&SetColor&=&IconImage.GetPixel(ReadIndex,&RowIndex);
&&&&&&&&&&&&&&&&&&&&if&(!Set[i-1])IconImage.SetPixel(ReadIndex,&RowIndex,&Color.FromArgb(255,&SetColor.R,&SetColor.G,&SetColor.B));
&&&&&&&&&&&&&&&&&&&&ReadIndex++;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&&&&&&&&&private&int&GetBitNumb(bool&BitArray)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&if&(BitArray)&return&1;
&&&&&&&&&&&&&&&&return&0;&&&&&&&&&&&&&&&&
&&&&&&&&&&&&}
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:458571次
积分:5723
积分:5723
排名:第4028名
原创:89篇
评论:421条
(1)(1)(1)(2)(1)(1)(2)(3)(1)(1)(4)(2)(4)(5)(4)(8)(4)(7)(7)(10)(10)(8)(1)(6)

我要回帖

更多关于 phpthumb ico 的文章

 

随机推荐