Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. void __fastcall TForm1::Button2Click(TObject *Sender)
  2. {
  3. //[Z1] - Zona 1
  4. if( Image1->Picture->Graphic->Empty ==true )
  5. return;
  6. //crearea unui bitmap sursa temporar
  7. Graphics::TBitmap *source = new Graphics::TBitmap;
  8. source->Assign( Image1->Picture->Bitmap );
  9. source->PixelFormat = Image1->Picture->Bitmap->PixelFormat;
  10.  
  11. // crearea si stabilirea unui bitmap destinatie temporar
  12. Graphics::TBitmap *dest = new Graphics::TBitmap;
  13. dest->Width = source->Width;
  14. dest->Height = source->Height;
  15. dest->PixelFormat = source->PixelFormat;
  16.  
  17. RGBTRIPLE* pixels;
  18. TColor color;
  19. int mtab[256];
  20. int nivel=10,j,k;
  21.  
  22. for(j=0;j<255;j++)
  23. {
  24. for(k=0;k<256;k+=nivel)
  25. {
  26. mtab[j++]=k;
  27. }
  28. for(k=255;k>0;k-=nivel)
  29. {
  30. mtab[j++]=k;
  31. }
  32. }
  33. mtab[255]=0;
  34.  
  35. for( int y=0; y<source->Height-1; y=y+2 )
  36. {
  37. pixels = (RGBTRIPLE*)source->ScanLine[y];
  38. for (int x=0; x<source->Width; x=x+1)
  39. {
  40. pixels[x].rgbtRed=mtab[pixels[x].rgbtRed];
  41. pixels[x].rgbtGreen=mtab[pixels[x].rgbtGreen];
  42. pixels[x].rgbtBlue=mtab[pixels[x].rgbtBlue];
  43. dest->Canvas->Pixels[x][y]=TColor(RGB(pixels[x].rgbtRed,pixels[x].rgbtGreen,pixels[x].rgbtBlue));
  44. }
  45. }
  46. //Asigneaza bitmapul destinatie inapoi catre Image1 si "curata"
  47. Image2->Picture->Bitmap = dest;
  48. delete dest; delete source;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement