Why do I get different results when I use MoveText vs SetFixedPosition? I use the same x and y value but they print on the page in different location. If I use canvasPage.BeginText can it be formatted to use a width and word wrap
canvasPage.BeginText()
.SetFontAndSize(PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD), 21)
.MoveText(X,Y)
Paragraph p = new Paragraph()
.Add(_disclaimer)
.SetFixedPosition(X,Y, canvasPage.W)
.SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA))
.SetFontColor(ColorConstants.BLACK)
.SetFontSize(12)
.SetTextAlignment(TextAlignment.LEFT);
The locations between the cases when you add text onto the canvas manually with low-level operations versus the case when you use high-level layout Paragraph objects will be different because Paragraph is responsible for multi-line layout and adds necessary margins / spacings for the text to look nice and not overlap with other content. The locations are still different only by a minor offset.
You cannot combine low-level beginText operation with high-level layout requirements (wrapping text across lines etc) - this is the responsibility of layout's Paragraph.
I want to merge resorces file, but user 1 has resources file with russian comments (his visual studio in english, but generates russian comments, like
/// <summary>
/// Ищет локализованную строку, похожую на ANPR camera images receiving error.
/// </summary>
but I need
/// <summary>
/// Looks up a localized string similar to ANPR camera images receiving error.
/// </summary>
And there are a lot of such points in resource file to merge in smart git.
What could be suggested to resolve my issue?
Appreciate any help.
I am trying to scale images/text etc using MM_ANISTROPIC and what I've done is the following (by the way if the syntax is a little weird, it's originally from delphi so treat the following as pseudocode)
I would expect the following code to produce a rectangle that is 70% of the width of the PaintBox and 30% of the height, yet it doesn't, instead it it noticeably too small.
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,100,100,0);
SetViewportExtEx(hdc,70,30,0);
Rectangle(hdc, 0,0,PaintBox.width-1,PaintBox.Height-1);
if, on the other hand I change the code so that the SetWindowExtEx has 91 instead of 100 as its parameters (as shown below) then it works, which makes no sense to me at all...
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,91,91,0);
SetViewportExtEx(hdc,70,30,0);
Rectangle(hdc, 0,0,PaintBox.width-1,PaintBox.Height-1);
My sanity test case was to add the following pseudocode
SetMapMode(hdc,MM_TEXT);
DrawLine(hdc,Round(PaintBox.width*0.7),0,Round(PaintBox.width*0.7),PaintBox.Height-1);
DrawLine(hdc,0,Round(PaintBox.height*0.3),PaintBox.width-1,Round(PaintBox.height*0.3));
I would have expected this to overwrite the lower / bottom edges of my original Rectangle but it does not unless I uses that 91,91 SetWindowExtEx.
Can anyone duplicate this?
FURTHER EDIT: Here is my exact original code I had given pseudo code before to make the question more accessible to non-delphi users but one of my commenters wanted full code to see if my contention that it was a delphi quirk was true or not.
The entire project consisted of a VCL form with a rectangular paintbox dropped on it centered so there was space all around it, and its onPaint event was set to the code below resulting in this image::
procedure TForm11.PaintBox2Paint(Sender: TObject);
var
hdc:THandle;
res:TPoint;
procedure SetupMapMode;
begin
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,100,100,0);
SetViewportExtEx(hdc,70,30,0);
// These lines are required when we're painting to a TPaintBox but can't be used
// if we're paiting to a TPanel and they were NOT in my original question but only
// got added as part of the answer
// SetViewportOrgEx(hdc,PaintBox2.Left,PaintBox2.Top,#ZeroPoint);
// SetWindowOrgEx(hdc,0,0,#ZeroPoint);
end;
begin
//draw a rectangle to frame the Paintbox Surface
PaintBox2.Canvas.Pen.Style:=psSolid;
PaintBox2.Canvas.Pen.width:=2;
PaintBox2.Canvas.Pen.Color:=clGreen;
PaintBox2.Canvas.Brush.Style:=bsClear;
PaintBox2.Canvas.Rectangle(0,0,PaintBox2.Width-1,PaintBox2.Height-1);
PaintBox2.Canvas.Brush.Style:=bsSolid;
//initialize convenience variable
hdc:=PaintBox2.Canvas.Handle;
SetTextAlign(hdc,TA_LEFT);
//as doing things to the PaintBox2.Canvas via Delphi's interface tends to reset
//everything, I'm ensuring the map mode gets set **immediately** before
//each drawing call
SetupMapMode;
/// Draw Text at the bottom of the PaintBox2.Canvas (though as it's mapped it
/// SHOULD be 1/3 of the way down and much smaller instead)
TextOut(hdc,200,PaintBox2.Height-PaintBox2.Canvas.TextHeight('Ap'),'Hello, World!',13);
PaintBox2.Canvas.Pen.Color:=clblue;
PaintBox2.Canvas.Brush.Style:=bsClear;
//ensure it's set before doing the rectangle
SetupMapMode;
// Redraw the same rectangle as before but in the mapped mode
Rectangle(hdc, 0,0,PaintBox2.Width-1,PaintBox2.Height-1);
PaintBox2.Canvas.Brush.Style:=bsSolid;
//reset the map mode to normal
SetMapMode(hdc,MM_Text);
//draw text at the "same" position as before but unmapped...
TextOut(hdc,200,PaintBox2.Height-PaintBox2.Canvas.TextHeight('Ap'),'Goodbye, World!',15);
//Draw lines exactly at 70% of the way across and 30% of the way down
//if this works as expected they should overwrite the right and bottom
//borders of the rectangle drawn in the mapped mode
PaintBox2.Canvas.Pen.Color:=RGB(0,255,255);
PaintBox2.Canvas.MoveTo(Round(PaintBox2.Width*0.7),0);
PaintBox2.Canvas.LineTo(Round(PaintBox2.Width*0.7),PaintBox2.Height);
PaintBox2.Canvas.MoveTo(0,Round(PaintBox2.Height*0.3));
PaintBox2.Canvas.LineTo(PaintBox2.Width,Round(PaintBox2.Height*0.3));
end;
Okay, I don't know WHY the following is necessary -- it may be a Delphi quirk, the fact that I'm using a TPaintBox with is a TGraphicControl rather than a Component, or if I'm missing out on some fundamental concept on how this whole mapping mode works, BUT if I add the following code:
ZeroPoint:=TPoint.Zero;
SetViewportOrgEx(hdc,PaintBox1.Left,PaintBox1.Top,#ZeroPoint);
SetWindowOrgEx(hdc,0,0,#ZeroPoint);
Then it all displays as expected. Anyone have any explanations as to why this is necessary?
EDIT: Okay, I've got a PARTIAL explanation. It has to do with the control I was painting on being a TPaintBox, which is a TGraphic control rather than a TWinControl. To wit:
TGraphicControl is the base class for all lightweight controls.
TGraphicControl supports simple lightweight controls that do not need the ability to accept keyboard input or contain other controls. Since lightweight controls do not wrap Windows screen objects, they are faster and user fewer resources than controls based on TWinControl.
As such, although they APPEAR to have a separate canvas, I have this sneaking feeling that they are really sharing the form's canvas which is why, when I switched to a TWinControl descendant, which DOES own its own Windows DC, then the display worked as expected without setting the ViewpointOrg.
So it was a Delphi quirk after all...!
I'd like to use the Google Tango motion tracking while taking pictures. The Tango service precludes using the android camera API. From what I can tell, it's not possible to control the camera (ISO, exposure, white balance) or take still shots while the Tango service is running. True?
The online java API documents show that TangoConfig has a constant called KEY_BOOLEAN_COLORMODEAUTO, but the TangoConfig class declaration in the TangoSDK_Leibnitz.jar does not have it. Is there a way to control the camera? If the java API does not support this, does the C API?
Theoretically, the OnFrameAvailable is what you want - it returns a regular image stream from the color or fisheye camera via callbacks. That said, it was busted several releases ago, and for the latest release (Leibnitz) there seems to be some confusion over format, and some concern over stability. DO NOT try and acquire the camera yourself, or Tango looses access to it
From what i can tell, you have access in C API (and latest Leibniz release) to disabling auto camera config and then set ISO params (i tried yesterday), and the cloud acquisition AND color frame acquistion is running fine. But this seems to be for Color Cam only ( not explicitly said, but FishEye seems not tunable like this).
Extract of comment from tango_client_api. h :
"
The supported configuration parameters that can be set are:
///
/// <table>
/// <tr><td class="indexkey">boolean config_color_mode_auto</td><td
/// class="indexvalue">
/// Use auto-exposure/auto-whitebalance with the color camera. Defaults to
/// true, and
/// if true, the values for config_color_iso and config_color_exp are ignored.
/// </td></tr>
///
/// <tr><td class="indexkey">int32 config_color_iso</td><td
/// class="indexvalue">ISO value for the color camera.
/// One of 100, 200, 400 or 800. Default is 100. Only applied if
/// config_color_mode_auto is set to false.</td></tr>
///
/// <tr><td class="indexkey">int32 config_color_exp</td><td class="indexvalue">
/// Exposure value for the color camera, in nanoseconds. Default is
/// 11100000 (11.1 ms). Valid from 0 to 30000000. Only applied if
/// config_color_mode_auto is set to false.</td></tr>
...
"
I use Graphviz (mainly dot and fdp) to automatically generate some diagrams that I need. For these diagrams I need some special arrowheads that are not a part of the standard collection of arrows: A small black triangle inside a large white triangle, and the same with the black triangle pointing downwards.
What is the best way to add such arrowheads? I don't mind hacking the source code, if necessary. Where should I start?
You have to change to source code for that. Take a look at "lib/common/arrows.c".
You will find that you have to:
Add a #define like ARR_TYPE_YOURARROWNAME
add a entry in Arrownames[] with the name you will use in the code for your arrow and the define.
write the prototype of your arrow function (see around row 115), read the points below
add your function in the Arrowtypes[] array an entry with the define you wrote previously, the pen width, the name of your arrow function which will be something like arrow_type_yourarrowname
write your own arrow function.
In order to write your function take a look at arrow_type_normal(), it takes 6 parameters: job (you don't have to care about this, just use it like in this function), two points ('p' and 'u'), arrowsize, penwidth and flag.
If you don't care about making different versions of your arrowhead, or if you wish to ignore the modifiers (inverted arrows and the like) ignore the flag parameter.
Then, the function basically takes the two points p and u (which are structures with 'x' and 'y' attributes in them) and combines them creating an array called a[] passed to gvrender_polygon() which will finally render your arrow shape.
arrow_type_normal() also mess with the penwidth and arrowwidth.
Summarizing: prepare graphviz to accept your arrow name doing the first steps then create a function that will create the arrow shape and that will call gvrender_polygon or gvrender_polyline (if you wish).
I didn't try yet, but it should work.