ActiveReports Change Image size at runtime - activereports

I have an image that is 300px width and has to be set at runtime. At design time, the image is a different size and depending on a flag, the image has to be changed. How do I set the image width in C#/VB.NET.
I cast the object as a Picture. The Width property only takes a SINGLE value and presume its inches. How do I tell the picture control that I'm passing in is the pixel size not inches?

Here's an example of how you can set the size in pixels, convert it to inches (as the GrapeCity Team suggests), and apply it to your picture based on a conditional variable:
The following code is added in the Script section of your report:
Sub Detail_Format
Dim intSizeInPixels As Integer = 300
Dim dblSizeInInches as Double = intSizeInPixels / 96
Dim mfFlag As Boolean = True
If mfFlag Then
Picture1.Width = dblSizeInInches
End If
End Sub

Related

Dynamically setting a 'targetSize' for centerCropWindow2d()

Following the example from the documentation page of the centerCropWindow2d function, I am trying to dynamically crop an image based on a 'scale' value that is set by the user. In the end, this code would be used in a loop that would scale an image at different increments, and compare the landmarks between them using feature detection and extraction methods.
I wrote some test code to try and isolate 1 instance of this user-specified image cropping,
file = 'frameCropped000001.png';
image = imread(file);
scale = 1.5;
scaled_width = scale * 900;
scaled_height = scale * 635;
target_size = [scaled_width scaled_height];
scale_window = centerCropWindow2d(size(image), target_size);
image2 = imcrop(image, scale_window);
figure;
imshow(image);
figure;
imshow(image2);
but I am met with this error:
Error using centerCropWindow2d (line 30)
Expected input to be integer-valued.
Error in testRIA (line 20)
scale_window = centerCropWindow2d(size(image), target_size);
Is there no way to do use this function the way I explained above? If not, what's the easiest way to "scale" an image without just resizing it [that is, if I scale it by 0.5, the image stays the same size but is zoomed in by 2x].
Thank you in advance.
I didn't take into account that the height and width for some scales would NOT be whole integers. Since Matlab cannot crop images that are inbetween whole pixel numbers, the "Expected input to be integer-valued." popped up.
I solved my issue by using Math.floor() on the 'scaled_width' and 'scaled_height' variables.

How to draw multi size using vispy?

I use following code to draw a point cloud in vispy
# init
view = vispy.sence.widgets.ViewBox()
vis = visuals.Markers()
view.add(vis)
# updata data
vis.set_data(data,
face_color = color,
edge_color=color,
size = 1
)
vispy.app.run
As you can see, I could set the fixed point size for whole data.
How can I set multi size in one data?
You should be able to set the size with a numpy array (one element for every marker point):
https://github.com/vispy/vispy/blob/932d6e499791a423822513549ebd825601345c85/vispy/visuals/markers.py#L517-L518
size : float or array
The symbol size in px.

Label text truncated after increasing font size

I followed the procedures in this question, and also tried setting individual text object with larger fonts. Here is my sample code:
hf = figure;
set(hf, 'DefaultAxesFontSize', 14)
hx = axes('Parent',hf);
[hx,hp1,hp2] = plotyy(hx, rand(10,1),rand(10,1),rand(10,1),rand(10,1),'scatter');
hlx = xlabel(hx(1), 'Only half of this line show up');
hl1 = ylabel(hx(1), 'Not usually truncated but less border');
hl2 = ylabel(hx(2), 'Only part of this line show up');
ht = title(hx(1), 'Too close to border');
As can be seen in the picture, the labels get truncated by the border of the figure. I have to drag the figure to very large - contrary to desired - in order to reveal all text.
How can I automatically set the text box according to the text font size, so that even for small graphs they don't get cut?
I know I can do it manually by setting Position of the axes but it's kind of manual and guess-and-try. Is there any automatic way to calculate the margins?
One thing that can be done is to calculate increased margin according to new text font size. Assume we know Matlab's default font size is 10, or otherwise get it by get(hf,'DefaultAxesFontSize').
Then get the relative position of the axes by get(hx, 'Position'), which gives four percentage values. First two define left and bottom margin. Since it's for the labels, increasing the font size from 10 to 14 means the text box should grow by 1.4 times. The next two numbers define the size of the axis. Since text boxes on both sides grow by 1.4 times, assuming original size being x, then new size is 1-[(1-x)*1.4] = 1.4x - 0.4.
Suggested workaround:
hf = figure;
set(hf, 'DefaultAxesFontSize', 14)
hx = axes('Parent',hf);
set(hx, 'Position', [1.4 1.4 1.4 1.4].*get(hx, 'Position')+ [0 0 -.4 -.4])
[hx,hp1,hp2] = plotyy(hx, rand(10,1),rand(10,1),rand(10,1),rand(10,1),'scatter');
hlx = xlabel(hx(1), 'Only half of this line show up');
hl1 = ylabel(hx(1), 'Not usually truncated but less border');
hl2 = ylabel(hx(2), 'Only part of this line show up');
ht = title(hx(1), 'Too close to border');
You may replace the manually entered number 1.4 with the ratio between newly assigned (bigger, hopefully) font size and the original size which is 10.

Set MinimumBlobArea with width and height - MATLAB

I have a project to detect an object with background subtraction. But I can only set minimumblobarea with minimum pixel.. in my case, I need to set minimunblobarea to detect object in width and height to get specific object.. example : if there is an object bigger than width and height that I've set before, that object can't be detected.. so what should I do?
I Use this code
http://www.mathworks.com/help/vision/examples/motion-based-multiple-object-tracking.html
vision.BlobAnalysis returns bounding boxes of the detected blobs. The bounding box is a 4-element array of the form [x, y, width, height]. Once you have the bounding boxes you can easily check with ones have the width or the height that is too big, and exclude them.
Let's say you have N bounding boxes returned by vision.BlobAnalysys as an N-by-4 matrix called bboxes. You can use logical indexing to find boxes that are too big:
bigBoxesIdx = (bboxes(:, 3) > maxWidth) | (bboxes(:,4) > maxHeight);
bigBoxesIdx is now a logical array, where you have 1's for boxes that are too big, and 0's for the ones that are not. Note that you have to use the |, which stands for "element-wise or", rather than ||.
Now to throw away the boxes that are too big you simply do
bboxes(bigBoxesIdx, :) = [];

How to shrink the size of the text inside a label

Im trying to get text to fill the entire bounds of a label no matter how long or short the text string is. I want the largest possible font size without any truncation or clipping.
I set up my label like so:
var messageTitle = TTTAttributedLabel()
messageTitle.setTranslatesAutoresizingMaskIntoConstraints(false)
messageTitle.font = AppTheme.largeMessageFont()
messageTitle.verticalAlignment = .Bottom
messageTitle.numberOfLines = 0
messageTitle.adjustsFontSizeToFitWidth = true
messageTitle.minimumScaleFactor = 0.2
And set the various constraints to set the size of the label to be 250 x 250.
I'm pretty sure this used to work. The label text now gets truncated if it is long when it should be shrinking the size of the text
You can set the font into maximum font size then add this attribut
theLabel.adjustsFontSizeToFitWidth = true
theLabel.minimumScaleFactor = 0.5 //this is the minimum scale factor, set it as small as you want