i am trying to display text using three js but the text displayed is slight diagonally and blur.
i am attaching screenshot.
The problem is that you don't set a resolution of your canvas. I've applied a value of 512x512 and also increased the font size. Your text should be more sharp now.
canvas.width = 512;
canvas.height = 512;
https://jsfiddle.net/f2Lommf5/6147/
BTW: Always use CanvasTexture in such scenarios. In this way, you don't have to set needsUpdate to true.
Related
I am getting my feet wet with JavaFX, and have a simple drawing program which writes to a Canvas using a PixelWriter. The program draws a pixel at a time, reflecting each pixel over a number of axes to create a growing and evolving pattern centered on the canvas:
The Canvas is in the Center region of a BorderPane, and I have written the code to resize the canvas when the application window is resized. That works OK.
However, I would like to re-center the image on the new resized canvas so that the drawing can continue to grow on the larger canvas. What might be the best approach?
My ideas/attempts so far:
Capture a snapshot of the canvas and write it back to the resized canvas, but that comes out blurry (a couple of code examples below).
I dug into GraphicsContext translations, but that does not seem to move the existing image, just adjusts future drawing.
Maybe instead of resizing the canvas, I make a huge canvas bigger than I would expect my app window to be, and center it over the center region of the border pane (perhaps using a viewport of some kind?) I'm not thrilled about the whole idea of making some arbitrarily huge canvas that I think will be big enough though. I don't want to get into scaling - I am using PixelWriter so that I get the crispest image without antialiasing and other processing.
My snapshot attempt looked like this, but was blurry:
SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.WHITE);
WritableImage image = canvas.snapshot(params, null);
canvas.getGraphicsContext2D().drawImage(image, 50, 50);
The 50, 50 offset above is just for my testing/learning - I'll replace it with a proper computed offset once I get the basic copy working. From the post How to copy contents of one canvas to another? I played with the setFill() parameter, to no effect.
From the post How to save a high DPI snapshot of a JavaFX Canvas I tried the following code. It was more clear, but I have not been able to figure out how to find or compute the pixelScale to get the most accurate snapshot (the value 10 is just some number I typed in bigger than 1 to see how it reacted):
int pixelScale = 10;
WritableImage image = new WritableImage((int)Math.rint(pixelScale * canvas.getWidth()),(int)Math.rint(pixelScale * canvas.getHeight()));
SnapshotParameters params = new SnapshotParameters();
params.setTransform(Transform.scale(pixelScale, pixelScale));
params.setFill(Color.WHITE);
canvas.snapshot(params, image);
canvas.getGraphicsContext2D().drawImage(image, 50, 50);
Thanks for any direction y'all can point me in!
I'm using the
Item.grabToImage()
But I'm getting the following error.
QML ItemX: grabToImage: item has invalid dimensions
This is because I'm using height and width properties like so:
width: {
// return with * 0.4; based for some condition
// for eg
return parent.width * 0.4;
}
// and something similar with height
The only time that I can get the following code working is when I put in a static heigth and width:
grabToImage(
function(result)
{
result.saveToFile("/path/project-name/tmp/something.png");
}
);
Any ideas of why and how do I get around this problem?
Thank you
I'm not a 100% sure why, But it was something about the dynamic width of the parent.
In the program I wrote I has set the anchors of the image to the left and right of the preview container.
So when I tried to get the image capture from another item that was overlaying the image to cut out smaller parts of the image it was not letting me.
How I fixed this was to set a fixed image size of the source image and then just anchor it to the center of the preview section.
The only thing is now it will not size up if you scale the window.
I'm sure I could implement and on size change to the main program window and then set the width of the image (Not tested).
Last thing I should mention is that if the image is small then the cut out images from sections of the source image will be blurry and not good quality.
I fixed this by setting the "sourceSize.width" to a very large image and then used the "scale" property to scale down the image to fit within the preview item.
I would like to add a few coloured square shapes to a form in order to display a legend. Since I haven't come across any way of adding coloured-in shapes, I've resorted to creating the shapes as images, loading them as resources and am currently trying to load them to the form...although this seems like a lengthy workaround for a simple single-coloured square.
First off, is there any way of adding a basic shape of a given colour to an AX form? Otherwise, is there any easier way of adding the image to the form without having to replicate the CompanyImage (or CompanyInfo) form?
NOTE: I'm looking to have the image stored within AX proper and not having the image linked by a filepath to an image on the local machine.
You can draw simple shapes with the WinGDI Class.
Here is a simple sample :
void drawShapes()
{
WinGDI winGDI;
Int brush, height, width;
;
//myWindow being the FormWindowControl
height = myWindow.heightValue()/2;
width = myWindow.widthValue()/2;
myWindow.lockDC();
winGDI = new WinGDI(myWindow.hDC());
brush = winGdi.createSolidBrush(WinAPI::RGB2int(0, 0, 255));
winGDI.fillRect(0, 0, width, height, brush);
winGDI.deleteObject(brush);
winGDI.ellipse(0, 0, width, height);
brush = winGdi.createSolidBrush(WinAPI::RGB2int(255, 0, 0));
winGDI.fillRect(width, height, 2*width, 2*height, brush);
winGDI.deleteObject(brush);
myWindow.UnlockDC();
}
I assume you got something similar.
Now if you just call it once in the form's init, the drawing's will be erased as soon as the paint method of the window control is called (and it's called pretty often).
So the easiest way is to call it in the paint method of the window. This way every time myWindow's content is redrawn, your shapes are too.
You can also force the redrawing of the shapes at a (short) regular time interval like the Tetris Tutorial does (look at the cycle method) using setTimeout but it may be overkill for static content.
You should now have this
You can store images as containers (BLOB) on the database and show them on a form or a report:
How to: Add an Image to a Form
This could be a simple workaround but this what i did for one of my changes. Since you wanted to use it for legend you can just add a button and set the property as flat, give it a color and a text. That should be good enough as a legend.
I am new to Matlab and to Image Processing as well, I know we can change image brightness by following formula if my image is I
newImg=imadjust(I, [low_in high_in], [low_out,high_out]);
it adjust all pixel's value of image but how can I do it on some part of image, like I detected face in the image now I want change its brightness how can I do it using imadjust.
Edit
I have detected area in a binary mask.
I done it please see the answer and also the reference in the answer.
I done it,
Well I wanted to change the brightness of some area of the image, the area which I wanted was calculated by a binary mask mask, So I did, First I simply change the brightness of my input Image I, and store the result in newImg like this
newImg = imadjust(I, [low_in high_in], [low_out,high_out]);
then apply mask on my orignal image and store value of masked area of newImg like this
I(mask) = newImg (mask);
Reference
I think its informative and not to bore anyone, If you guys wont motivate me then I cant learn, as people closed my thread just because I was asking questions, and I am using same database of Image for different type of projects.
%Suppose these are the coordinates of the rectangle in which the face is detected%
%You can do the following to adjust the brightness of that region
topLeft = 10;
topRight = 50;
bottomLeft = 50;
newImg = I;
newImg(topLeft:bottomLeft,topLeft:topRight) = imadjust(newImg(topLeft:bottomLeft,topLeft:topRight), [low_in high_in], [low_out,high_out]);
I'm trying to export an HTML page to PDF with ABCpdf. The text converts OK but the charts are very blurry. I've tried increasing the font size and it helps very little. What could be the solution?
EDIT: I'm using the asp.net charts if that helps.
You'll need to output the charts at a higher DPI. Not sure if you can do this with abcpdf though.
I am assuming your chats are images? If so the reason for the blur is that the DPI on the HTML image is 72 DPI and the DPI of the rendered pdf is 300 DPI.
The only way I know round this is to have the images in the HTML a much higher resolution (300 DPI) then reduce the size with a set height and width on the page. When ABCPdf imports the image it will download the source and look much nicer.
Other answers are on the right track, but not quite there.
The browser "usually" displays things at 96 DPI. This depends on settings but we're pretty safe to assume here. The PDF is going to scale to 72 DPI. So you need your Rect to be set to 3/4 the browser width. Then your images will look correct.
As a side effect you may end up needing a higher resolution image in order to get the size you want (you can increase the resolution of an image by the inverse, i.e. by a factor of 4/3 to achieve parity with what you'd see in a browser).
Using the code below, your images will never blur (though you may need to adjust your expected document width; a PDF with a width of 612pt # 72 DPI (letter-sized portrait orientation, for example) needs to be backed by a browser width of 816px # 96 DPI):
const Double pdfDpi = 72;
const Double browserDpi = 96;
var browserToPdfDpiRatio = BrowserDpi / PdfDpi;
pdf.HtmlOptions.BrowserWidth = (Int32)Math.Round(pdf.Rect.Width * browserToPdfDpiRatio, 0);