ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 From ImageXpress to ImageEn
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

BReeves

USA
11 Posts

Posted - Feb 23 2016 :  06:20:10  Show Profile  Reply
In the process of moving a few apps from C++ Builder 5 to Builder XE5.
Among other functions, have been using the Merge() function in ImageXpress to create combined images on a blank canvas. The folks at ImageXpress have priced themselves out of my reach and thinking of buying ImageEn to replace it.

Guess my question is..
What functions are in ImageEn to preform the following?
1. Create a blank 1088 X 210 image.
2. Open 3 images (of course 1 at a time) that are 1280 X 720.
3. Resize to 356 X 200 and place in appropriate place on blank canvas.
4. Save the result as a JPG and display it with a TImage.

Might make more sense if I posted the code for ImageXpress.


{
int hstart, hoffset, margin;
char fname[MAX_PATH];
String file;

    hstart = 5;
    hoffset = 361; // Horz location of next image
    margin = 5;
    ImagXPr1->CreateDIB(1088, 210, 24, 16777215);
                             // 24 bit, white background
    ImagXPr1->AreaOpt(true, hstart, margin , 356, 200);
    ImagXPr1->MergeOpt(true, 2, 0, false, 0, 0, 0);
    file = RawPath;
    file += "1.BMP";
    ImagXPr1->FileName = file;

    ImagXPr1->AreaOpt(true, hstart + hoffset, margin, 356, 200);
    ImagXPr1->MergeOpt(true, 2, 0, false, 0, 0, 0);
    file = RawPath;
    file += "2.BMP";
    ImagXPr1->FileName = file;

    ImagXPr1->AreaOpt(true, hstart + (hoffset * 2), margin, 356, 200);
    ImagXPr1->MergeOpt(true, 2, 0, false, 0, 0, 0);
    file = RawPath;
    file += "3.BMP";
    ImagXPr1->FileName = file;

    sprintf(fname, "%s%04d.JPG", StripPath, Rd.Last);
    ImagXPr1->SaveFileName = fname;  // Save strip..
    ImagXPr1->SaveFile();
}


Thanks
Bob

spetric

Croatia
308 Posts

Posted - Feb 23 2016 :  07:23:39  Show Profile  Reply
Ok, a fast one (may contain errors):


//1. instantiate imageenProc
TImageEnProc *ienProc = new TImageEnProc(0);

//2. create blank image and fill it with white
TIEBitmap *imgMain = new TIEBitmap(1088, 210, ie24RGB);
imgMain->Fill(clWhite);

//3. create and load images 
TIEBitmap *imgMap[3];
UnicodeString imgName[3];
imgName[0] = "sample1.bmp";
imgName[1] = "sample2.bmp";
imgName[2] = "sample3.bmp";
// 4. positions on the main image
TPoint imgPts[3]; // fill them please

for (int i = 0; i < 3; i++)
    {
    imgMap[i] = new TIEBitmap();
    imgMap[i]->Read(imgName[i]);	
    ienProc->AttachedIEBitmap = imgMap[i]; 	
    ienProc->Resample(356, 200, rfNone /* or some resample filter */); 
    imgMap[i]->CopyRectTo(imgMain, 0, 0, imgPts[i].x, imgPts[i].y, imgMap[i]->Width, imgMap[i]->Height); 	
    ienProc->AttachedIEBitmap = 0;
    delete imgMap[i];
    }

delete ienProc; 
// display result - let's assume that component View (instance of TImageEnView) is already on the form
View->AssignImage(imgMain);
delete imgMain;
// there are also alternative approaches, but this will work...probably.


Note: I'm not using TImage as TImageEnView is far better for displaying images.
Also, avoid using TBitmap, use TIEBitmap instead.
Go to Top of Page

BReeves

USA
11 Posts

Posted - Feb 23 2016 :  07:58:26  Show Profile  Reply
Thanks a million, that will get me in the ball park. Going to be enough of an ordeal making the transition from Builder 5 to XE5. Not real sure I like the XE5 GUI but that will probably come with more experience.

In Builder 5 I'm just using a TImage to display the resulting image as it's easy and does what I need. Learning XE5 components is going to take a little time :)
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Feb 23 2016 :  08:40:33  Show Profile  Reply
Hi,

TImage is also available in XE5 (currently I'm using also XE5 C++), as well as TBitmap, but
with ImageEn you don't need TImage for displaying, ImageEn has it's own viewer with bunch of controls (zooming, layers, etc...).

You can use TBitmap with ImageEn, but I recommend to use ImageEn TIEBitmap class instead of TBitmap.
Go to Top of Page

BReeves

USA
11 Posts

Posted - Feb 27 2016 :  02:26:41  Show Profile  Reply
This is what I ended up with (at least for now). May not be the most efficient but it works. Loaded the view from the saved file only because in the end it will not be displayed when it is created.

Sure appreciate the help, great product and support.

//---------------------------------------------------------------------------
void TGrabForm::CreateStrip(void)
{
char fname[MAX_PATH];
int hstart, hoffset, margin;
//2. create blank image and fill it with white
	TIEBitmap *imgMain = new TIEBitmap(1088, 210, ie24RGB);
	imgMain->Fill(clWhite);

//3. create and load images
	TIEBitmap *imgMap[3];
	AnsiString imgName[3];
	imgName[0] = RawPath;
	imgName[0] += "1.bmp";
	imgName[1] = RawPath;
	imgName[1] += "2.bmp";
	imgName[2] = RawPath;
	imgName[2] += "3.bmp";
// 4. positions on the main image
	hstart = 5;
	hoffset = 361;
	margin = 5;
	TPoint imgPts[3]; // fill them please
	imgPts[0].X = hstart;
	imgPts[0].y = margin;
	imgPts[1].X = hstart + hoffset;
	imgPts[1].y = margin;
	imgPts[2].X = hstart + (hoffset * 2);
	imgPts[2].y = margin;

	for (int i = 0; i < 3; i++) {
		imgMap[i] = new TIEBitmap();
		imgMap[i]->Read(imgName[i]);
		ImageEnProc1->AttachedIEBitmap = imgMap[i];
		ImageEnProc1->Resample(356, 200, rfNone /* or some resample filter */);
		imgMap[i]->CopyRectTo(imgMain, 0, 0, imgPts[i].x, imgPts[i].y, imgMap[i]->Width, imgMap[i]->Height);
		ImageEnProc1->AttachedIEBitmap = 0;
		delete imgMap[i];
	}
	sprintf(fname, "%s%04d.JPG", StripPath, Rd.Last);
	imgMain->Write(fname);
	delete imgMain;

	// display result - let's assume that component View (instance of TImageEnView) is already on the form
	ImageEnView1->IO->LoadFromFile(fname);
}
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: