fork download
  1. unsigned char* ptr = 0;
  2. int R=0,G=0,B=0;
  3. int R1=0,B1=0,G1=0;
  4. for (int Y=0;Y<this->Image1->Height;Y++)
  5. {
  6. ptr = static_cast<unsigned char*>(this->Image1->Picture->Bitmap->ScanLine[Y]);
  7. for (int X=0;X<this->Image1->Width;X++)
  8. {
  9. B = ptr[3*X];
  10. G = ptr[3*X+1];
  11. R = ptr[3*X+2];
  12.  
  13. ptr[3*X] = 0.299*R + 0.587*G + 0.114* B;
  14. ptr[3*X+1] = ptr[3*X+2] = ptr[3*X];
  15. }
  16. }
  17. this->Image1->Refresh();
  18. for (int Y=0;Y<this->Image2->Height;Y++)
  19. {
  20. ptr = static_cast<unsigned char*>(this->Image2->Picture->Bitmap->ScanLine[Y]);
  21. for (int X=0;X<this->Image2->Width;X++)
  22. {
  23. B = ptr[3*X];
  24. G = ptr[3*X+1];
  25. R = ptr[3*X+2];
  26.  
  27. /*
  28.   B1 = GetBValue(this->Image2->Canvas->Pixels[X][Y]);
  29.   G1 = GetGValue(this->Image2->Canvas->Pixels[X][Y]);
  30.   R1 = GetRValue(this->Image2->Canvas->Pixels[X][Y]);
  31.   if (B!= B1 || G!= G1 || R!= R1)
  32.   int a=0; //為了下中斷點看RGB值使用
  33.   */
  34.  
  35. ptr[3*X] = 0.299*R + 0.587*G + 0.114* B;
  36. ptr[3*X+1] = ptr[3*X+2] = ptr[3*X];
  37. }
  38. }
  39. this->Image2->Refresh();
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty