fork download
  1. void TMDIChild::Scale()
  2. {
  3. Byte *tptr,*dptr;
  4. Graphics::TBitmap *AttendBitmap=new Graphics::TBitmap();
  5. AttendBitmap=OriginalBitmap;
  6. AttendBitmap->PixelFormat=pf24bit;
  7. AttendBitmap->Width=OriginalBitmap->Width;
  8. AttendBitmap->Height=OriginalBitmap->Height;
  9. Graphics::TBitmap *TempBitmap=new Graphics::TBitmap();
  10. TempBitmap->Assign(OriginalBitmap);
  11. TempBitmap->PixelFormat=pf24bit;
  12. int down,right;
  13. int w,h,newW,newH;
  14. double dX,dY,x,y;
  15. double scalar; // Zoom scalar
  16. int i,j;
  17. int ix,iy; // integer value of (x,y)
  18. float fx,fy; // float value of (x,y)
  19. unsigned char clr,
  20. clrR,clrG,clrB,
  21. nclr1,nclr2,nclr3,nclr4; // color of neighbor 4 pixel
  22.  
  23. w = AttendBitmap->Width;
  24. h = AttendBitmap->Height;
  25. scalar = StrToFloat(ScaDlg->Edit1->Text);
  26. newW=(int)((double)w*scalar);
  27. newH=(int)((double)h*scalar);
  28. TempBitmap->Width=newW;
  29. TempBitmap->Height=newH;
  30. /* Caculate the step size of movement */
  31. dX = (double)w/(double)newW;
  32. dY = (double)h/(double)newH;
  33. for(j = 0 ; j < newH ; j++)
  34. {
  35. y = dY*(double)j;
  36. iy = (int)y;
  37. fy = y - (float)iy;
  38. down=iy+1;
  39. if (down==h)
  40. down=0;
  41. tptr=(Byte*)AttendBitmap->ScanLine[iy];
  42. dptr=(Byte*)AttendBitmap->ScanLine[down];
  43. for(i =0 ; i < newW;i++)
  44. {
  45. x = dX*(double)i;
  46. ix = (int)x;
  47. fx = x - (float)ix;
  48. right=ix+1;
  49. if (right==w)
  50. right=0;
  51. nclr1=tptr[3*ix+2];
  52. nclr2=tptr[3*right+2];
  53. nclr3=dptr[3*ix+2];
  54. nclr4=dptr[3*right+2];
  55. // Bilinear
  56. clrR=(Byte)((1.0-fx)*(1.0-fy)*(double)nclr1+(fx)*(1.0-fy)
  57. *(double)nclr2+(1.0-fx)*(fy)*(double)nclr3+(fx)*(fy)*(double)nclr4);
  58.  
  59. nclr1=tptr[3*ix+1];
  60. nclr2=tptr[3*right+1];
  61. nclr3=dptr[3*ix+1];
  62. nclr4=dptr[3*right+1];
  63. // Bilinear
  64. clrG=(Byte)((1.0-fx)*(1.0-fy)*(double)nclr1+(fx)*(1.0-fy)
  65. *(double)nclr2+(1.0-fx)*(fy)*(double)nclr3+(fx)*(fy)*(double)nclr4);
  66.  
  67. nclr1=tptr[3*ix];
  68. nclr2=tptr[3*right];
  69. nclr3=dptr[3*ix];
  70. nclr4=dptr[3*right];
  71. // Bilinear
  72. clrB=(Byte)((1.0-fx)*(1.0-fy)*(double)nclr1+(fx)*(1.0-fy)
  73. *(double)nclr2+(1.0-fx)*(fy)*(double)nclr3+(fx)*(fy)*(double)nclr4);
  74. TempBitmap->Canvas->Pixels[i][j] = (TColor)RGB(clrR,clrG,clrB);
  75. }
  76. }
  77. Image1->Width=newW;
  78. Image1->Height=newH;
  79. OriginalBitmap->Width=newW;
  80. OriginalBitmap->Height=newH;
  81. Image1->Picture->Bitmap=TempBitmap;
  82. Image1->Picture->Assign(TempBitmap);
  83. OriginalBitmap=TempBitmap;
  84. OriginalBitmap->Assign(TempBitmap);
  85. delete AttendBitmap,TempBitmap;
  86. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1: error: ‘TMDIChild’ has not been declared
prog.cpp: In function ‘void Scale()’:
prog.cpp:3: error: ‘Byte’ was not declared in this scope
prog.cpp:3: error: ‘tptr’ was not declared in this scope
prog.cpp:3: error: ‘dptr’ was not declared in this scope
prog.cpp:4: error: ‘Graphics’ has not been declared
prog.cpp:4: error: ‘AttendBitmap’ was not declared in this scope
prog.cpp:4: error: expected type-specifier before ‘Graphics’
prog.cpp:4: error: expected `;' before ‘Graphics’
prog.cpp:5: error: ‘OriginalBitmap’ was not declared in this scope
prog.cpp:6: error: ‘pf24bit’ was not declared in this scope
prog.cpp:9: error: ‘Graphics’ has not been declared
prog.cpp:9: error: ‘TempBitmap’ was not declared in this scope
prog.cpp:9: error: expected type-specifier before ‘Graphics’
prog.cpp:9: error: expected `;' before ‘Graphics’
prog.cpp:25: error: ‘ScaDlg’ was not declared in this scope
prog.cpp:25: error: ‘StrToFloat’ was not declared in this scope
prog.cpp:41: error: expected primary-expression before ‘)’ token
prog.cpp:41: error: expected `;' before ‘AttendBitmap’
prog.cpp:42: error: expected primary-expression before ‘)’ token
prog.cpp:42: error: expected `;' before ‘AttendBitmap’
prog.cpp:74: error: ‘TColor’ was not declared in this scope
prog.cpp:74: error: expected `;' before ‘RGB’
prog.cpp:77: error: ‘Image1’ was not declared in this scope
prog.cpp:85: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
prog.cpp:19: warning: unused variable ‘clr’
stdout
Standard output is empty