91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 7KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-09
  • 語言: 其他
  • 標簽:

資源簡介

c實現的wu反走樣算法,編譯可運行,是一種很好的反走樣反鋸齒算法,Michael Abrash強烈推薦的算法

資源截圖

代碼片段和文件信息

void?DrawWuLine(?CDC?*pDC?int?X0?int?Y0?int?X1?int?Y1?COLORREF?clrLine?)//clrline表示要畫線的顏色?
{????pDC->SetPixel(?X0?Y0?clrLine?);????
????int?XDir?DeltaX?=?X1?-?X0;?
????if(?DeltaX?>=?0?)????{?
????????XDir?=?1;????}?
????else????{?
????????XDir??=?-1;?
????????DeltaX?=?0?-?DeltaX;?/*?make?DeltaX?positive?*/?
????}?
????XDir?=?1;?
??????????unsigned?short?ErrorAdj;?
????unsigned?short?ErrorAccTemp?Weighting;?
????
????/*?Line?is?not?horizontal?diagonal?or?vertical?*/?
????unsigned?short?ErrorAcc?=?0;??/*?initialize?the?line?error?accumulator?to?0?*/?
????
????BYTE?rl?=?GetRValue(?clrLine?);?
????BYTE?gl?=?GetGValue(?clrLine?);?
????BYTE?bl?=?GetBValue(?clrLine?);?
????double?grayl?=?rl?*?0.299?+?gl?*?0.587?+?bl?*?0.114;?
????
????/*?Is?this?an?X-major?or?Y-major?line??*/?
????if?(DeltaY?>?DeltaX)?
????{?
????/*?Y-major?line;?calculate?16-bit?fixed-point?fractional?part?of?a?
????pixel?that?X?advances?each?time?Y?advances?1?pixel?truncating?the?
????????result?so?that?we?won‘t?overrun?the?endpoint?along?the?X?axis?*/?
????????ErrorAdj?=?((unsigned?long)?DeltaX?????????/*?Draw?all?pixels?other?than?the?first?and?last?*/?
????????while?(--DeltaY)?{?
????????????ErrorAccTemp?=?ErrorAcc;??/*?remember?currrent?accumulated?error?*/?
????????????ErrorAcc?+=?ErrorAdj;??????/*?calculate?error?for?next?pixel?*/?
????????????if?(ErrorAcc?<=?ErrorAccTemp)?
{?
????????????????/*?The?error?accumulator?turned?over?so?advance?the?X?coord?*/?
????????????????X0?+=?XDir;?
????????????}?
????????????Y0++;?/*?Y-major?so?always?advance?Y?*/?
??????????????????/*?The?IntensityBits?most?significant?bits?of?ErrorAcc?give?us?the?
??????????????????intensity?weighting?for?this?pixel?and?the?complement?of?the?
????????????weighting?for?the?paired?pixel?*/?
????????????Weighting?=?ErrorAcc?>>?8;?
????????????ASSERT(?Weighting?????????????ASSERT(?(?Weighting?^?255?)?????????????
????????????COLORREF?clrBackGround?=?::GetPixel(?pDC->m_hDC?X0?Y0?);?
????????????BYTE?rb?=?GetRValue(?clrBackGround?);?
????????????BYTE?gb?=?GetGValue(?clrBackGround?);?
????????????BYTE?bb?=?GetBValue(?clrBackGround?);?
????????????double?grayb?=?rb?*?0.299?+?gb?*?0.587?+?bb?*?0.114;?
????????????
????????????BYTE?rr?=?(?rb?>?rl???(?(?BYTE?)(?(?(?double?)(?grayl?????????????BYTE?gr?=?(?gb?>?gl???(?(?BYTE?)(?(?(?double?)(?grayl?????????????BYTE?br?=?(?bb?>?bl???(?(?BYTE?)(?(?(?double?)(?grayl?

評論

共有 條評論

相關資源