AS3 PrintJob blurry text - actionscript-3

Does anyone know why PrintJob produces such a low quality blurry results and how to fix this?

This is because HtmlLoader renders itself as a bitmap with screen resolution (around 72 dpi). I got decent result printing it following way:
Scale up html body by setting style zoom:400% on it (via JavaScript function injected into page)
Scale it down to normal with scale=0.25 (on HtmlLoader object)
(got idea from here)
This raises resolution of HtmlLoader bitmap in factor of 4. Pictures will stay blurry (if they have screen resolution), but text will be OK.

Related

HTML canvas expand beyond page but elements remain the same when it showing correctly

I am running a html game inside an iFrame. The game is displaying on a canvas.
I am testing the game on Chrome mobile simulator Pixel 5 device size 851x393
I was testing to see whether game display correctly when the user rotate the device.
portrait mode window.innerwith/height is showing as 851 1843
landscape mode window.innerwith/height is showing as 851 393
I am also puzzled, how can innter width/height change when the device rotate?
But the game does display correctly. Following are the elements of each state
Landscape
Portrait
With these settings the game display correctly.
When I rotate the device few times, the game got expand beyond the screen, as if we are looking at a zoomed upper left hand corner of the game.
However the elements seems to be exact match when it display correctly before. Even though game is not displaying correctly now.
Can anyone provide some assistance on this ?

In img tag, image dimension has been changed dynamically

I've captured a photo from in apple iphone 5s.
Dimension of the image is 960x1280.
Horizontal and vertical resolution is 72 dpi, Bit depth 24.
When I show the image in the img tag, the image is automatically rotated from portrait to horizontal.
But when I see the actual image, but the image is in computer in portrait mode only.
I don't know where is the issue.
I've opened in the ms paint to. I didn't get the issue.
I really confused in this. I've opened the image(which is in portrait mode) in ms paint and saved again in the same portrait mode itself. Now I've showed in the img tag, now the image is showing correctly in portrait mode itself in img tag. No issue has occurred. Working perfectly. Why the ios image is dynamically changing from portrait to horizontal?. I've checked with [http://imgur.com/ ]. The same issue has occurred in this application too.
How to resolve this?
Sometimes when you take a photo with an iPhone it embeds orientation information in the Exif metadata. Some applications understand this, some don't (web browsers don't), so you see different results.
Saving in MS Paint or, for example, "Save for Web" in Photoshop saves the image in the correct orientation, and strips the Exif data. You can also manually rotate the image on your phone, which will actually change the pixels, rather than just the Exif data.

Webgl Distortion in Chrome with three Monitors

I'm developing a webgl application (a simple solar system) and everything looks fine on Chrome and Firefox on ONE monitor
But if I start eyefinity (three monitors each full hd + bezel compensation) the solarsystem is distorted in chrome.
In Firefox it looks correct and really nice:
http://kritten.org/pictures/firefox.jpg
In Chrome it looks like this:
http://kritten.org/pictures/chrome.jpg
It seems that the principal point (is this the right name?) is in the wrong location.
If I move forward in Firefox I actually move forward, but in Chrome I move to the right. So it keeps this distortion any time.
Are there any ideas what could be wrong?
The issue with Chrome is it's got a limit on the size a canvas can be. This is part of the WebGL spec although arguably Chrome should fix it. You can try to encourage them to fix it here.
The specific issue is that the WebGL spec says that even though you may ask for a canvas of a certain size WebGL might give you a smaller drawingbuffer. This was specifically because graphics cards have a size limit. Some are as low as 1024. Let's say some card has a limit of 2048. You've got one monitor that's 1280x1024. No problem.
You now add a second monitor for a total desktop space of 2560x1024. You now stretch a window across both monitors. You ask for a canvas of size 2560x1024. What should happen? WebGL can't make one that big, the GPU says it has a limit of 2048. So there were 3 option
Crash. That's no go
Force the canvas to stay under 2048
Let the canvas be stretched to 2560 but make the drawingbuffer the limit which is 2048 in this example
The WebGL committee picked #3 because it's the one least likely to cause problems. The worst that happens is you get a distorted image but the user can scale the window back down until things are normal so your webpage doesn't die.
Unfortunately 99.99% of WebGL programs ignore this feature of WebGL and so you get this distorted image when you run into that part of the spec.
In this particular case though the limit isn't in your GPU it's in Chrome. The proof is that it works in Firefox. Again you can try to encourage them to fix it here.
If you'd like to make your program work around it you need to look up what size the canvas's drawing buffer was actually made and use that in the correct places. You can find out but checking gl.drawingBufferWidth and gl.drawingBufferHeight
That means first set the camera aspect to the size the canvas is actually displayed. You really should always do this
aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;
perspective = yourPerspectiveFunction(fov, aspect, zNear, zFar);
In three.js that would be
camera.aspect = renderer.domElement.clientWidth /
renderer.domElement.clientHeight;
camera.updateProjectionMatrix();
You should set your viewport to the size of the drawingbuffer
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawBufferHeight);
In three.js that would be
renderer.setViewport(0, 0, renderer.context.drawingBufferWidth,
renderer.context.drawingBufferHeight);
That should also always work.
If you're doing anything else related to the width and height of the canvas (picking, scissor, etc..) you'll need to do the appropriate math to convert from the size the canvas is being displayed to the size of its drawingbuffer
That will get rid of the distortion, of course since Chrome will actually only be creating a smaller drawingBuffer you'll get some scaling.

AIR Project Dimensions for Retina Support

I am a bit confused with how the project dimensions I set up in Flash Develop will affect my AIR Application's appearance on Retina and non-Retina iPad displays, and how to work with Bitmaps under these circumstances.
When I run in Flash Player on PC to debug the 2048x1536 is off of my monitor it's so big. I've heard that the stage will scale with the size of the screen, and is just a reference coordinate system, but I don't understand how Bitmaps would work in these conditions... Are the Bitmaps scaled automatically all too? Does it matter whether I set my project dimensions to 2048x1546?
My hesitance to get started with this is that I will be using some spritesheets via Starling and I am confused with how to treat their dimensions in these circumstances.
Plz set me straight if you have knowledge and a minute. Appreciated.
You don't have to use 2048x1536. You can just use 1024x768 for your project dimensions. Make sure that stage.scaleMode = StageScaleMode.SHOW_ALL; but that's the default if I'm not mistaken.
Retina iPads will just show it doubled, so everything gets scaled up to 2048x1536. That means your bitmaps won't look as sharp as they can be, but vector graphics DO look sharp because Flash uses the extra resolution on a retina screen.
You could write some code to use higher-resolution bitmaps if you're on a retina display but I don't actually know of a good way of detecting retina resolution other than checking the screen dimensions. Or you could use high-resolution bitmaps that will be scaled down on non-retina screens (make sure to allow smoothing).
Also, I don't have experience with Starling myself so that may behave differently. Hope this helps a bit anyway.

Get device physical size using CSS3

I have an HTML5 page using CSS3 and SVG graphics in development. I tried using media queries to enlarge the SVG graphics when the device pixel ratio is 1.5 or 2. This works fine. Now I view my page on a small device like the Motorolla Xoom. The reported ratio is 1. This means the Xoom displays everything quite small as compared to a regular monitor. The most annoying part is that it looks great in landscape mode, but in portrait mode the full page is resized to fit in the same width. The ratio number does not change at this point.
I did try using something like 'width: 3in;' but again, it was only the correct size in landscape.
Ultimately, I'd like to use some ratio of device size vs pixel size, and scale everything this way. Is this possible?
My issue was that my graphics were never rendered again when orientation was changed. When I hit refresh again, all is coming up as expected. This was an issue that existed somewhere between my keyboard and my chair. The media queries are in fact working, I just need to rerender some stuff upon orientation change.