最新の更新情報

2012年5月
« 4月    
 12345
6789101112
13141516171819
20212223242526
2728293031  

本ブログのURL

qrcode.png

お天気

 
このブログ「吟遊詩人の戯言」 の記事検索...

Bitmapオブジェクトの画像バッファよりIntPtrを取り出す方法


キーワード(クリックで関連記事が読めます) → ,

関連記事



 
 

C#の画像処理
Bitmapオブジェクトに、画像を格納した上で
あ~だこ~だやるわけですが

Bitmapオブジェクトを利用して実装すると、なんか処理が遅い

ってことで、unsafeしちゃって、ポインタでかき回す、ってのが、王道なんですが

その前に、Bitmapオブジェクト内に格納されている、バッファへのポインタを取り出す必要がありまして

その取り出し方は、以下のとおり

C#:
  1. Bitmap b = new Bitmap(720,480, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  2.  
  3. BitmapData bData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
  4.                            ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
  5.  
  6. IntPtr Scan0 = bData.Scan0//取り出されたIntPtr
  7.  
  8. //IntPtrに格納されているバッファへのアドレスを利用して、ごにょごにょする
  9.  
  10. b.UnlockBits(bData);


Bitmap.LockBits();
Bitmap.UnLockBits();

と、生成されたBitmapDataクラスのScan0プロパティが肝ですな

 
 
 
 

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">