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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Shaped text bounding rectangle

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
spetric Posted - Jul 07 2014 : 00:17:40
Hi,

It seems that method DrawOneObjectToBitmap does not properly calculate shaped text (SetObjTextCurveShape) bounding rectangle. It cuts out a portion of shaped text.

In ImageEn vesrion 3.xx I've used DrawOneObjectToBitmap to put shaped text in 8-bit mask and then render some 24-bit image using mask with shaped text.

In version 3.xx DrawOneObjectToBitmap worked OK. As bounding rectangle does not correspond to object's coordinates, I've adjust bounding rectangle (used for rendering) via font metrics data and rendering worked fine.

In version 5.xx DrawObjectToBitmap cuts out a portion of text no matter if it's drawn on 8-bit mask or 24-bit image. I've tried both options without any bounding rectangle...ie. on complete image area.

Any suggestions?
7   L A T E S T    R E P L I E S    (Newest First)
spetric Posted - Jul 16 2014 : 03:15:02
I made some workaround:

In OnMouseUp event I simply cloned iekMEMO parameters in new object and set ObjPenColor to clWhite. Old object is removed and new (cloned) object is rendered properly with full intensity.

However, there is another issue:

In OnMouseMove event, user can resize iekMEMO object/text. Now, memo box is resized properly, but font size inside the box remains as is (although it's set to autosize). Cloned object text size is Ok an it's again rendered properly.

Maybe there is something with iekMEMO object refreshing, as single line text (iekTEXT) manipulation in OnMouseMove event (text rotating, resizing), works well.
spetric Posted - Jul 10 2014 : 12:13:35
Now, you wan't believe this:

In OnMouseDown event, depending on text type selected (normal text, curved, memo)
I'm creating proper object, and setting the ObjPenColor to user defined color, which is clRed in attached pictures.

In OnMouseMove event, object is moved, resized, rotated, etc...

In OnMouseUp event, ObjPenColor is changed to clWhite and object is rendered onto grayscale mask.

When object of type iekTEXT is used, everything works OK and object is rendered with 255 value. However, when iekMEMO is used ObjPenColor does not change to clWhite and of course, it's rendered as clRed.

I've put clBlack in OnMouseUp event and iekTEXT is not rendered, which is ok, because mask is now empty, but iekMEMO is still rendered.

I've also set ObjPenColor to clWhite in OnMOuseDown event (when object is freshly created) and of course, text is rendered with full intensity, no matter what ObjPenColor is put in OnMouseUp event.

I've also tried to change ObjPenColor in OnMouseMove event..no color change occurred with iekMEMO. With iekTEXT object, pen color has changed.

Sometimes, when debugging, ObjPenColor of iekMEMO object changes to clWhite, probably due to hiding view with IDE editor and repainting view, but not always.

Very strange. I'll try to perform debugging when program's GUI/view is moved to secondary monitor.

Edit: I've tried to render iekMEMO directly to 24-bit image , with color changed (in OnMouseUp event):


ImageContainer->PaintView->ObjMemoBorderColor[_hobj]    = clGreen;
ImageContainer->PaintView->ObjPenColor[_hobj] = clBlack;
ImageContainer->PaintView->DrawOneObjectToBitmap(_hobj, ImageContainer->ImageOrig->ieBitmap, true, false);
ImageContainer->PaintView->RemoveObject(_hobj);


Now, border color (which was clRed in OnMouseDown event), changed to clGreen, but ObjPenColor did not change to clBlack and memo text was rendered in red with green border.


xequte Posted - Jul 10 2014 : 10:42:09
Hi

We cannot replicate this. When we test the code below we get a maximum value of 255 (except for the character edging because of the antialiasing).


var
  temp_bmp: TIEBitmap;
  hobj: integer;
begin
  temp_bmp := TIEBitmap.Create();
  temp_bmp.PixelFormat := ie8g;
  temp_bmp.Width  := 500;
  temp_bmp.Height := 500;
  temp_bmp.Fill(0);
  ImageEnVect1.ObjText[-1] := 'Test';
  ImageEnVect1.ObjPenColor[-1] := clWhite;
  imageenvect1.ObjFontHeight[-1] := 60;
  imageenvect1.SetObjRect(-1, rect(10, 10, 200, 100));
  imageenvect1.ObjKind[-1] := iekMEMO;
  hobj := ImageEnVect1.AddNewObject();
  ImageEnVect1.DrawOneObjectToBitmap(hobj, temp_bmp, true, false);

  // test
  if temp_bmp.Pixels_ie8[27, 41] <> 255 then
    ShowMessage('Test failed!');

  imageenvect1.RemoveAllObjects;

  // just to see something
  ImageEnVect1.LegacyBitmap := false;
  ImageEnVect1.IEBitmap.assign(temp_bmp);
  ImageEnVect1.Update();

  temp_Bmp.free;
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
spetric Posted - Jul 10 2014 : 03:29:27
Thanks Nigel, that's great.

What about iekMEMO issue when rendering onto 8-bit grayscale image?
xequte Posted - Jul 09 2014 : 22:44:53
Hi

We have now fixed the issue of rotated text when using CopyObjectsToBack. It will be available in v5.1.2.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
spetric Posted - Jul 09 2014 : 00:21:43
Here are examples:

1. In first example, I've changed my code and simply drawn iekTEXT object on 24-bit IEBitmap (the same bitmap attached to IenVect). Text object (arc shape)
can be moved around the the IenVect, it's curvature, size, rotation can be adjust using ctrl-shift-alt keys. On mouseup event, rendering is performed. There is no bounding rectangle, just two instructions:


ImageContainer->PaintView->DrawOneObjectToBitmap(_hobj, ImageContainer->ImageOrig->ieBitmap, true, false);
ImageContainer->PaintView->RemoveObject(_hobj);


You can see, that a portion of rendered object is cropped.



2. This example shows iekMEMO rendering onto grayscale image (code is in my second post in this thread). So, this time, I draw memo to grayscale mask and then perform rendering, using grayscal image pixels value as intensity to draw text over original 24-it image (with black color). Note, that pixel values are not 0xff as supposed to be. When simple one line text is drawn, using the same code, it's drawn with full intensity value.



Disregard the difference with memo text border. It's used only while previewing the object. When mouse button is released, border is drawn (or not) depending on parameter set in program.

Here is an example how this stuff works (17:00-24:00):

http://www.youtube.com/watch?v=rmJIP4svKkA
spetric Posted - Jul 07 2014 : 03:00:34
Here is another difference in version's behavior:

This is a part of code that draws textual objects (iekTEXT, iekMEMO):


TIEBitmap *temp_bmp = new TIEBitmap();
temp_bmp->PixelFormat = ie8g;
temp_bmp->Width  = boundRect->Width();
temp_bmp->Height = boundRect->Height();
temp_bmp->Fill(0);
curr_view->ObjPenColor[hobj]   = clWhite; //white-all channels to max value
if (antialias)
   curr_view->ObjFontQuality[hobj] =  iefqClearType;
else
   curr_view->ObjFontQuality[hobj] =  iefqDraft;
curr_view->ObjGraphicRender = antialias;
curr_view->DrawOneObjectToBitmap(hobj, temp_bmp, antialias, false);
curr_view->ObjGraphicRender = false;


When object is of type iekTEXT, text is rendered onto grayscale image with max value (0xff). However, when iekMEMO object is rendered onto grayscale image, it's not rendered with max value, but with value 0x35(!?)

Any clue?