Home > Back-end >  Want to make up a larger C program, C
Want to make up a larger C program, C

Time:09-29

Is the user to input images into the program, the program image into black and white and gray information of various points into a matrix to store, how to operate? Want to process is divided into several modules, and where should write, how together?
Hope to have detailed explanation,,, thank you

CodePudding user response:

Use TBitMap - & gt; LoadFromFile loading pictures, and then set PixelFormat to black and white, save
#include //For STL auto_ptr class

Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
STD: : auto_ptr & lt; Graphics: : TBitmap> Bitmap (new Graphics: : TBitmap);
STD: : auto_ptr & lt; Graphics: : TBitmap> BigBitmap (new Graphics: : TBitmap);
TRGBTriple * PTR, * bigPtr;//Use a (byte *) for pf8bit color.
TPixelFormat pixForm bigpixForm;
Try
{
Bitmap - & gt; LoadFromFile ("../littlefac. BMP ");
PixForm=Bitmap - & gt; PixelFormat;
BigpixForm=BigBitmap - & gt; PixelFormat;
Bitmap - & gt; PixelFormat=pf24bit;
BigBitmap - & gt; PixelFormat=pf24bit;
BigBitmap - & gt; Height=Bitmap - & gt; Height * 2;
BigBitmap - & gt; Width=Bitmap - & gt; Width * 2;
For (int y=0; Y & lt; Bitmap - & gt; Height; Y++)
{
PTR=reinterpret_cast & lt; TRGBTriple * & gt; (Bitmap - & gt; ScanLine [y]);
For (int x=0; X & lt; Bitmap - & gt; Width; X++)
{
Int bx=x * 2;
Int by=y * 2;
BigPtr=reinterpret_cast & lt; TRGBTriple * & gt; (BigBitmap - & gt; ScanLine [by]);
BigPtr [bx]=PTR [x];
BigPtr [bx + 1]=PTR [x];
BigPtr=reinterpret_cast & lt; TRGBTriple * & gt; (BigBitmap - & gt; ScanLine [by + 1));
BigPtr [bx]=PTR [x];
BigPtr [bx + 1]=PTR [x];
}
}
Canvas - & gt; The Draw (0, 0, Bitmap. The get ());
Canvas - & gt; The Draw (200, 200, BigBitmap. The get ());
}
The catch (... )
{
ShowMessage (" Could not load the or alter bitmap ");
}
}

CodePudding user response:

If you look at the OpenCV, it is quite simple thing!