日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Silverlight寫圖像功能特點詳解

Silverlight對于圖像的處理是比較強大的。主要可以通過Bitmap API來實現(xiàn)Silverlight寫圖像。在這里我們將會為大家詳細介紹這一功能的實現(xiàn)方式,希望能對大家有所幫助,提高編程效率。#t#

石峰ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

新版的Bitmap API支持從寫每個像素的值來創(chuàng)建自己的圖像。這個用來支持生成Bitmap的類叫做WriteableBitmap,繼承自BitmapSource類。這個類位于System.Windows.Media.Imaging名字空間中,其函數(shù)成員包括:

  1. public sealed class WriteableBitmap 
    : BitmapSource   
  2. {   
  3. public WriteableBitmap(BitmapSource source);   
  4. public WriteableBitmap(int pixelWidth, 
    int pixelHeight, PixelFormat format);   
  5. public int this[int index] { get; set; }   
  6. public void Invalidate();   
  7. public void Lock();   
  8. public void Render(UIElement 
    element, Transformtransform);   
  9. public void Unlock();   

可以看出我們可以通過兩種Silverlight寫圖像的形式來實例化這個WriteableBitmap。一個是通過傳入已經(jīng)初始化了的BitmapSource,另外一個是通過輸入圖像高度和寬度以及像素類型(有Bgr32和Pbgra32兩種,后面一種可以創(chuàng)建半透明圖像)。第5行的索引this[int index]可以用來讀或取像素點。

寫一個WriteableBitmap的流程是這樣的。實例化WriteableBitmap,調(diào)用Lock方法,寫像素點,調(diào)用Invalidate方法,最后是調(diào)用Unlock方式來釋放所有的Buffer并準備顯示。

如下文所示以描點的方式構(gòu)建了整個Bgr32圖像

 
 
 
  1. private WriteableBitmap BuildTheImage
    (int width, int height)   
  2. {   
  3. WriteableBitmap wBitmap=new Writeable
    Bitmap(width,height,PixelFormats.Bgr32);   
  4. wBitmap.Lock();   
  5. for (int x = 0; x < width; x++)   
  6. {   
  7. for (int y = 0; y < height; y++)   
  8. {   
  9. byte[] brg = new byte[4];   
  10. brg[0]=(byte)(Math.Pow(x,2) % 255); 
    //Blue, B   
  11. brg[1] = (byte)(Math.Pow(y,2)
     % 255); //Green, G   
  12. brg[2] = (byte)((Math.Pow(x, 2) + Mat
    h.Pow(y, 2)) % //Red, R   
  13. brg[3] = 0;   
  14. int pixel = BitConverter.
    ToInt32(brg, 0);   
  15. wBitmap[y * height + x] = pixel;   
  16. }   
  17. }   
  18. wBitmap.Invalidate();   
  19. wBitmap.Unlock();    
  20. return wBitmap;   

Silverlight寫圖像的實現(xiàn)方法就為大家介紹到這里。


當(dāng)前名稱:Silverlight寫圖像功能特點詳解
文章起源:http://m.5511xx.com/article/cddgdse.html