2008-05 月份文章 顯示方式:簡文 | 列表

May 28,2008

Direct Memory Access in C#

Quoted from http://www.codeproject.com/KB/GDI-plus/csharpfilters.aspx

 
public static bool Conv3x3(Bitmap b, ConvMatrix m)
{
// Avoid divide by zero errors

if (0 == m.Factor)
return false; Bitmap

// GDI+ still lies to us - the return format is BGR, NOT RGB.

bSrc = (Bitmap)b.Clone();
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);
BitmapData bmSrc = bSrc.LockBits(new Rectangle(0, 0, bSrc.Width, bSrc.Height),
ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
int stride2 = stride * 2;

System.IntPtr Scan0 = bmData.Scan0;
System.IntPtr SrcScan0 = bmSrc.Scan0;

unsafe {
byte * p = (byte *)(void *)Scan0;
byte * pSrc = (byte *)(void *)SrcScan0;
int nOffset = stride - b.Width*3;
int nWidth = b.Width - 2;
int nHeight = b.Height - 2;

int nPixel;

for(int y=0;y < nHeight;++y)
{
for(int x=0; x < nWidth; ++x )
{
nPixel = ( ( ( (pSrc[2] * m.TopLeft) +
(pSrc[5] * m.TopMid) +
(pSrc[8] * m.TopRight) +
(pSrc[2 + stride] * m.MidLeft) +
(pSrc[5 + stride] * m.Pixel) +
(pSrc[8 + stride] * m.MidRight) +
(pSrc[2 + stride2] * m.BottomLeft) +
(pSrc[5 + stride2] * m.BottomMid) +
(pSrc[8 + stride2] * m.BottomRight))
/ m.Factor) + m.Offset);

if (nPixel < 0) nPixel = 0;
if (nPixel > 255) nPixel = 255;
p[5 + stride]= (byte)nPixel;

nPixel = ( ( ( (pSrc[1] * m.TopLeft) +
(pSrc[4] * m.TopMid) +
(pSrc[7] * m.TopRight) +
(pSrc[1 + stride] * m.MidLeft) +
(pSrc[4 + stride] * m.Pixel) +
(pSrc[7 + stride] * m.MidRight) +
(pSrc[1 + stride2] * m.BottomLeft) +
(pSrc[4 + stride2] * m.BottomMid) +
(pSrc[7 + stride2] * m.BottomRight))
/ m.Factor) + m.Offset);

if (nPixel < 0) nPixel = 0;
if (nPixel > 255) nPixel = 255;
p[4 + stride] = (byte)nPixel;

nPixel = ( ( ( (pSrc[0] * m.TopLeft) +
(pSrc[3] * m.TopMid) +
(pSrc[6] * m.TopRight) +
(pSrc[0 + stride] * m.MidLeft) +
(pSrc[3 + stride] * m.Pixel) +
(pSrc[6 + stride] * m.MidRight) +
(pSrc[0 + stride2] * m.BottomLeft) +
(pSrc[3 + stride2] * m.BottomMid) +
(pSrc[6 + stride2] * m.BottomRight))
/ m.Factor) + m.Offset);

if (nPixel < 0) nPixel = 0;
if (nPixel > 255) nPixel = 255;
p[3 + stride] = (byte)nPixel;

p += 3;
pSrc += 3;
}

p += nOffset;
pSrc += nOffset;
}
}

b.UnlockBits(bmData);
bSrc.UnlockBits(bmSrc);
return true;
}

Posted by toki_kanno at 11:28回應(0)引用(0).Net Framework

May 10,2008

ER Monster 新車入替 :P

因為

一、黑色漆的車實在是超難顧的
二、黑色太灰暗了
三、為了我的某個某項改裝計畫XD

上星期去了彩繪王(在桃園,真是遠啊)做了全車90%烤漆(前後土除沒動)
本來說要烤兩星期的,昨天打電話去問了一下,居然提早一星期完工
趕緊去人事部改成下星期再補之前五一彈性放假的班,今天麻煩家人去桃園幫我載烤漆完的零件回來

下午去了車店把零件一一上車,也拍了一些相片,效果比意料中的還好
下面是相本的 link,有興趣的自己去看吧 :P


20080510 - ER6N 換色

Posted by toki_kanno at 18:48回應(0)引用(0)SuperBike

May 5,2008

NTLEA - NT全域通

用來代替applocale的工具軟體

http://www.comicfishing.com/thbbsin/read.php?tid=18497

Posted by toki_kanno at 0:24回應(0)引用(0)
 [1]