/** basically, it converts =) it's just a converter, basically */ void convert (AnsiString textfile, AnsiString bmpfile) { int i,j,left=5,top=5,x=left,y=top; Graphics::TBitmap *Bitmap = new Graphics::TBitmap; TExprClass *Expr; char Str[10000]; Bitmap->Width = 1000; Bitmap->Height = 4000; TList *Text = loadText(textfile, new TList); #ifdef DEBUG for(int i=0; i<Text->Count; ++i) printf("\"%s\"\n", (char *)Text->Items[i]); #endif /* Text->Add("String(\"# Тема - JOB \")"); Text->Add("String(\"Вариант 1, задача 1.\")"); Text->Add("String(\"Вычислить предел:\")"); Text->Add("lim(x->4, (-3*x^2+15*x)/(3*x^2+15*x))=..."); Text->Add("String(@Часть преподавателя )"); Text->Add("String(\"Тема - JOB \")"); Text->Add("String(ВАРИАНТ 1, решение задачи 1, ключ 865)"); Text->Add("lim(x->4, (-3*x^2+15*x)/(3*x^2+15*x))=(1/9)"); */ TFont *font = new TFont; font->PixelsPerInch = 1000; font->Name = "Trebuchet MS"; font->Size=10; for(i=0; i<Text->Count; i++) { strcpy(Str, (char*)Text->Items[i]); Expr = BuildExpr(Str); Expr->Canvas = Bitmap->Canvas; Expr->Font = font; Expr->Draw(left, y, 1000, 4000); y = y + Expr->Height; if (x<Expr->Width) x = Expr->Width; delete Expr; } Bitmap->Width = x+left + 5; Bitmap->Height = y + 5; Bitmap->SaveToFile(bmpfile); delete Bitmap; delete font; }
void __fastcall TMatdet::Button4Click(TObject *Sender) { Graphics::TBitmap * bmv = new Graphics::TBitmap(); if ( !Memo1->Lines->Count ) Button1->Click(); /*Memo1->Lines->SaveToFile("txtout.txt"); WinExec("txt2bmp.exe",SW_SHOWDEFAULT); Preview->Image1->Picture->LoadFromFile("out.bmp");*/ TxtToBmp( Memo1->Lines, bmv, qvar->FontDialog1->Font, 0, 0 ); bmv->SaveToFile( "out.bmp" ); Preview->ImageEnIO1->LoadFromFile( "out.bmp" ); //Preview->ImageEnProc1->Resample( -1, Screen->Height - 40, rfBSpline ); unlink( "out.bmp" ); delete bmv; Preview->ShowModal(); }
/* 1. 103 0 241 2. 91 0 241 3. 24 0 240 4. 0 121 231 5. 0 194 209 6. 0 255 164 7. 0 255 0 8. 136 232 0 9. 173 219 0 10. 201 204 0 11. 244 172 0 12. 255 134 0 13. 255 86 0 14. 255 0 0 */ void __fastcall TMainForm::ViewPalette1Click(TObject *Sender) { Graphics::TBitmap* bmp = new Graphics::TBitmap(); bmp->Width = 1920; bmp->Height = 1080; bmp->Canvas->Brush->Color = clWhite; TRect rect; rect.left = 0; rect.top = 0; rect.right = 1920; rect.top = 1080; bmp->Canvas->FillRect(rect); rect.left = 70; rect.top = 60; rect.right = 1850; rect.bottom = 1050; bmp->Canvas->Pen->Color = clRed; bmp->Canvas->Pen->Width = 3; bmp->Canvas->Rectangle(rect); int count = 0; for (int y = 0; y < 48; y++) { for (int x = 0; x < 54; x++) { if (count >= m_database.Count)/*this->m_Entries->Count*/ continue; TRect r; r.left = 80+ x*32; r.right = 80+ x*32 +32; r.top = 80+ y*26; r.Bottom = 80 + y*26+26; if (r.top > 500) { r.top += 100; r.bottom += 100; } TPantoneColorEntry* ee = m_database.Get(count);//(TPantoneColorEntry*)m_Entries->Items[count]; bmp->Canvas->Brush->Color = (TColor)RGB(ee->Red, ee->Green, ee->Blue); bmp->Canvas->FillRect(r); count++; } } bmp->Canvas->Brush->Color = clBlack; rect.left = 800; rect.right = 1120; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*1*/ bmp->Canvas->Brush->Color = (TColor)RGB( 103, 0, 241);; rect.left = 80; rect.right = 100; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*2*/ bmp->Canvas->Brush->Color = (TColor)RGB( 103, 0, 241);; rect.left = 100; rect.right = 120; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*3*/ bmp->Canvas->Brush->Color = (TColor)RGB( 24, 0, 240);; rect.left = 120; rect.right = 140; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*4*/ bmp->Canvas->Brush->Color = (TColor)RGB( 0, 121, 231);; rect.left = 140; rect.right = 160; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*5*/ bmp->Canvas->Brush->Color = (TColor)RGB(0, 194, 209);; rect.left = 160; rect.right = 180; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*6*/ bmp->Canvas->Brush->Color = (TColor)RGB( 0 , 255, 164);; rect.left = 180; rect.right = 200; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*7*/ bmp->Canvas->Brush->Color = (TColor)RGB( 0, 255, 0);; rect.left = 200; rect.right = 220; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*8*/ bmp->Canvas->Brush->Color = (TColor)RGB( 136 , 232, 0);; rect.left = 220; rect.right = 240; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*9*/ bmp->Canvas->Brush->Color = (TColor)RGB(173, 219, 0);; rect.left = 240; rect.right = 260; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*10*/ bmp->Canvas->Brush->Color = (TColor)RGB( 201, 204, 0);; rect.left = 260; rect.right = 280; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*11*/ bmp->Canvas->Brush->Color = (TColor)RGB( 244, 172, 0);; rect.left = 280; rect.right = 300; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*12*/ bmp->Canvas->Brush->Color = (TColor)RGB( 103, 0, 241);; rect.left = 300; rect.right = 320; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*13*/ bmp->Canvas->Brush->Color = (TColor)RGB( 255, 86, 0);; rect.left = 320; rect.right = 340; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); /*14*/ bmp->Canvas->Brush->Color = (TColor)RGB( 255, 0,0);; rect.left = 340; rect.right = 360; rect.top = 522; rect.bottom = 622; bmp->Canvas->FillRect(rect); bmp->SaveToFile(L"pantone.bmp"); delete bmp; PaletteForm->Show(); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::IdTCPServerExecute(TIdPeerThread *AThread) { AnsiString s; AnsiString sCommand; AnsiString sAction; TFileStream* tmpfStream; Graphics::TBitmap *tbm; try { s = UpperCase(AThread->Connection->ReadLn("",5000)); sCommand = s.SubString (1,3); sAction = s.SubString(5,s.Length()-4); if (sCommand == "LST") { AThread->Connection->WriteLn(GetList()); AThread->Connection->Disconnect(); } else if (sCommand == "PIC") { if (FileExists(ExtractFileDir(ParamStr(0)) + "\\images\\" + sAction)) { lstRequests->Items->Add("Serving up: " + sAction); // open file stream to image requested tmpfStream = new TFileStream(ExtractFileDir(ParamStr(0)) + "\\images\\" + sAction,fmOpenRead |fmShareDenyNone); // copy file stream to write stream AThread->Connection->OpenWriteBuffer(-1); AThread->Connection->WriteStream(tmpfStream,true,false); AThread->Connection->CloseWriteBuffer(); // free the file stream delete tmpfStream; tmpfStream=NULL; lstRequests->Items->Add("File transfer completed"); AThread->Connection->Disconnect(); } else {AThread->Connection->WriteLn("ERR - Requested file does not exist"); AThread->Connection->Disconnect(); } } else if (sCommand == "SRN") { // in production version you would use a unique file name such as one generated // from a tickcount plus clint IP / id etc. // take snapshot lstRequests->Items->Add("Taking screen snap shot"); tbm = new Graphics::TBitmap(); ScreenShot(0,0,Screen->Width,Screen->Height,tbm); if (FileExists (ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP")) DeleteFile(ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP"); tbm->SaveToFile(ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP"); tbm->FreeImage(); delete tbm; tbm=NULL; lstRequests->Items->Add("Serving up: SCREENSHOT.BMP"); // open file stream to image requested tmpfStream = new TFileStream(ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP",fmOpenRead | fmShareDenyNone); // copy file stream to write stream AThread->Connection->OpenWriteBuffer(-1); AThread->Connection->WriteStream(tmpfStream,true,false); AThread->Connection->CloseWriteBuffer(); // free the file stream delete tmpfStream; tmpfStream=NULL; lstRequests->Items->Add("File transfer completed"); AThread->Connection->Disconnect(); } else if ((sCommand != "LST") && (sCommand != "PIC") && (sCommand != "SRN")) { AThread->Connection->WriteLn("ERR : Unknown command / action"); AThread->Connection->Disconnect(); } } catch (Exception& E) { ShowMessage(E.Message); } }