народ, я что-то начертал похожее на мою задумку Антиалиазинга:
Код | Graphics::TBitmap *big_bmp = new Graphics::TBitmap(); Graphics::TBitmap *out_bmp = new Graphics::TBitmap(); Graphics::TBitmap *orig_bmp = new Graphics::TBitmap(); orig_bmp->LoadFromFile(ExtractFilePath(Application->ExeName) + "\\b.bmp");
big_bmp->Width = (orig_bmp->Width); big_bmp->Height = (orig_bmp->Height); big_bmp->Canvas->StretchDraw(big_bmp->Canvas->ClipRect,orig_bmp); out_bmp->Width = orig_bmp->Width; out_bmp->Height = orig_bmp->Height; out_bmp->PixelFormat = pf24bit; big_bmp->PixelFormat = pf24bit; orig_bmp->PixelFormat = pf24bit; int x, y, cx, cy; int totr, totg, totb; Byte *Row1, *Row2, *Row3, *Row4, *DestRow; int i; try // вот не до конца в этих своих закопках понял про Line Count :) { for(y = 0; y <= orig_bmp->Height-1; y++) { cy = y*4; Row1 = (Byte *)big_bmp->ScanLine[cy]; Row2 = (Byte *)big_bmp->ScanLine[cy+1]; Row3 = (Byte *)big_bmp->ScanLine[cy+2]; Row4 = (Byte *)big_bmp->ScanLine[cy+3]; DestRow = (Byte *)out_bmp->ScanLine[y];
for(x = 0; x <= orig_bmp->Width-1; x++) { cx = 4*x;
totr = 0; totg = 0; totb = 0;
for( i = 0; i <= 3; i++) { totr += GetRValue(Row1[cx + i]) + GetRValue(Row2[cx + i]) + GetRValue(Row3[cx + i]) + GetRValue(Row4[cx + i]); totg += GetGValue(Row1[cx + i]) + GetGValue(Row2[cx + i]) + GetGValue(Row3[cx + i]) + GetGValue(Row4[cx + i]); totb += GetBValue(Row1[cx + i]) + GetBValue(Row2[cx + i]) + GetBValue(Row3[cx + i]) + GetBValue(Row4[cx + i]); } DestRow[x] = RGB(totr / 16,totg / 16,totb / 16); } }
} catch(...) {} // думаете для чего он сволочь тут? Canvas->Draw(0,0,out_bmp);
|
я тут что-то недодумал с количеством ScanLine и почему-то цвет вертикальных линий получается зеленоватым, вместо черного! мож кто свежым взглядом провьювит?
вот выкладываю данный сэмпл в сорце C++Builder (прикреплен файл) |