Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- //[Z1] - Zona 1
- if( Image1->Picture->Graphic->Empty ==true )
- return;
- //crearea unui bitmap sursa temporar
- Graphics::TBitmap *source = new Graphics::TBitmap;
- source->Assign( Image1->Picture->Bitmap );
- source->PixelFormat = Image1->Picture->Bitmap->PixelFormat;
- // crearea si stabilirea unui bitmap destinatie temporar
- Graphics::TBitmap *dest = new Graphics::TBitmap;
- dest->Width = source->Width;
- dest->Height = source->Height;
- dest->PixelFormat = source->PixelFormat;
- RGBTRIPLE* pixels;
- TColor color;
- int mtab[256];
- int nivel=10,j,k;
- for(j=0;j<255;j++)
- {
- for(k=0;k<256;k+=nivel)
- {
- mtab[j++]=k;
- }
- for(k=255;k>0;k-=nivel)
- {
- mtab[j++]=k;
- }
- }
- mtab[255]=0;
- for( int y=0; y<source->Height-1; y=y+2 )
- {
- pixels = (RGBTRIPLE*)source->ScanLine[y];
- for (int x=0; x<source->Width; x=x+1)
- {
- pixels[x].rgbtRed=mtab[pixels[x].rgbtRed];
- pixels[x].rgbtGreen=mtab[pixels[x].rgbtGreen];
- pixels[x].rgbtBlue=mtab[pixels[x].rgbtBlue];
- dest->Canvas->Pixels[x][y]=TColor(RGB(pixels[x].rgbtRed,pixels[x].rgbtGreen,pixels[x].rgbtBlue));
- }
- }
- //Asigneaza bitmapul destinatie inapoi catre Image1 si "curata"
- Image2->Picture->Bitmap = dest;
- delete dest; delete source;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement