FSplitterMain.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <Graphics.hpp>
  4. #pragma hdrstop
  5. #include "FSplitterMain.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12. : TForm(Owner)
  13. {
  14. SetCurrentDir(ExtractFilePath(ExtractFileDir(Application->ExeName))+"\\Data");
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::Button1Click(TObject *Sender)
  18. {
  19. TPicture *pic;
  20. Graphics::TBitmap *bmp, *bmp2;
  21. int s, sd, f;
  22. int x, y;
  23. s = StrToInt(EDTileSize->Text);
  24. pic = new TPicture();
  25. if (RBHalf->Checked)
  26. f = 2;
  27. else if (RBLow->Checked)
  28. f = 4;
  29. else f = 1;
  30. sd = s/f;
  31. ProgressBar->Position = 0;
  32. Screen->Cursor = crHourGlass;
  33. bmp = new Graphics::TBitmap();
  34. bmp->PixelFormat = pf24bit;
  35. bmp->Width = sd;
  36. bmp->Height = sd;
  37. if (f != 1) {
  38. bmp2 = new Graphics::TBitmap();
  39. bmp2->PixelFormat = pf24bit;
  40. bmp2->Width = s;
  41. bmp2->Height = s;
  42. } else bmp2 = NULL;
  43. LAAction->Caption = "Loading Jpeg texture...";
  44. LAAction->Visible = true;
  45. Refresh();
  46. pic->LoadFromFile(EDFile->Text);
  47. x = 0; while (x<pic->Width) {
  48. y = 0; while (y<pic->Height) {
  49. if (sd != s) {
  50. bmp2->Canvas->Draw(-x, -y, pic->Graphic);
  51. bmp->Canvas->StretchDraw(Rect(0, 0, sd, sd), bmp2);
  52. } else bmp->Canvas->Draw(-x, -y, pic->Graphic);
  53. LAAction->Caption = Format("Generating tile %d-%d...", ARRAYOFCONST((x/s, y/s)));
  54. Refresh();
  55. bmp->SaveToFile(Format(EDMask->Text, ARRAYOFCONST((x/s, y/s))));
  56. ProgressBar->StepBy(1);
  57. y += s;
  58. }
  59. x += s;
  60. }
  61. delete bmp2;
  62. delete bmp;
  63. delete pic;
  64. Screen->Cursor = crDefault;
  65. LAAction->Caption = "Completed";
  66. ShowMessage("Done!");
  67. Application->Terminate();
  68. }
  69. //---------------------------------------------------------------------------