Windows metro app UI messes in high resolution devices when SwapChainBackgroundPanel is replaced by SwapChainPanel - winrt-xaml

I am developing winRt metro application. I was using SwapChainBackgroundPanel in UI for showing video content.
I recently replaced it by SwapChainPanel because Microsoft recommends it.
But now the UI is stretched beyond the screen.
If I don't convert dips to pixels while resizing swapchain buffers , The UI looks fine.
I am seeing this problem in Surface pro 3 and other high resolution devices

Beginning with SwapChainPanel, you have to take the properties CompositionScaleX and CompositionScaleY into consideration.
Just before m_swapChain->GetBuffer(), insert the following code:
// Setup inverse scale on the swap chain
DXGI_MATRIX_3X2_F inverseScale = { 0 };
inverseScale._11 = 1.0f / m_swapChainPanel->CompositionScaleX;
inverseScale._22 = 1.0f / m_swapChainPanel->CompositionScaleY;
ComPtr<IDXGISwapChain2> spSwapChain2;
DX::ThrowIfFailed(
m_swapChain.As<IDXGISwapChain2>(&spSwapChain2)
);
DX::ThrowIfFailed(
spSwapChain2->SetMatrixTransform(&inverseScale)
);

Related

Customizing JSXgraph fullscreen mode?

Fullscreen mode in JSXgraph always adds big gray margins around the board, giving the impression I don't take full advantage of a big screen. Can one configure fullscreen mode, so as to minimize the use of these margins?
This is a good question / suggestion! Up to version 1.4.6 it is not possible to configure the size of the JSXGraph board in the fullscreen window.
since this property is hard-coded with the value of 0.85.
I just added the new board attribute scale to the source code, available in the fullscreen attribute object:
const board2 = JXG.JSXGraph.initBoard('jxgbox', {
axis:true,
boundingbox:[-5,5,5,-5],
showFullscreen: true,
fullscreen: {
scale: 0.99
}
});
var pol = board.create('polygon', [[0, 1], [3,4], [-1,-4]]);
The default value of the attribute will be 0.85. This feature will be available in the upcoming 1.4.7 version.

Fast drawing/rendering 2d image texture

I am freaking out to solve my software flickering while running/processing images.
First, I'll introduce my problem, explaining what I did, then at the end I'll leave my questions/needs:
My software process images and shows it imediatelly on screen, acting like a scanner. The image pixels is built using image photosensors, processed using OpenCV, and draw as soon as possible on screen to provide a smooth movement while the image is generated.
In practice, I first have a white-solid 1000x808 blank image, which its pixels are replaced with respective photosensored built-image and is show on the screen so that the image flows from the left to the right on the screen.
The entire process of each frame generation lasts about 10 ~ 12ms.
However, The frames does not flows as expected on screen. It flickers a lot. As I have no Idea how to measure FPS on OpenGL, I suppose my OpenGL code (which I know nothing about OpenGL at all) is causing the flickering.
I am using the following code on my GLWidget, which I did my best to write but I am quite sure that it is not OpenGL best-performance-written.
I have almost nothing on my GLWidget constructor, but I have playing around with these functions, with no significant effect:
QGLFormat glFormat;
glFormat.setSwapInterval(0);
glFormat.setDoubleBuffer(true);
glFormat.setSampleBuffers(true);
glFormat.setDirectRendering(true);
glFormat.setSamples(4);
setFormat(glFormat);
My initializeGL is shown as follows:
initializeGL()
{
glClearColor(255.0f,255.0f,255.0f,0.1f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,this->width(), this->height(), 0.0f,0.0f,1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glGenTextures(3, &this->texture);
glBindTexture(GL_TEXTURE_2D, this->texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, this->width(), this->height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glDisable(GL_TEXTURE_2D);
this->original = cv::Mat(this->height(), this->width(), CV_8UC4);
memset(this->original.data, 0xff, this->original.rows * this->original.step);
this->repaint = true;
}
As you can see, at this point a blank image sized 1000x808 (screen size) is shown on initialization (because images aren't built yet)
When the images starts to being built (every 5 column) I send the image (through setImage) to the screen, then it renders with OpenGL on overriden paintGL function:
setImage(cv::Mat imageRGBA)
{
this->original = imageRGBA;
this->repaint = true;
update();
}
paintGL()
{
if (this->repaint) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, this->texture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, this->original.cols, this->original.rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->original.data );
glBegin(GL_QUADS);
glTexCoord2f(0,1); glVertex2f(0,this->height());
glTexCoord2f(0,0); glVertex2f(0,0);
glTexCoord2f(1,0); glVertex2f(this->width(),0);
glTexCoord2f(1,1); glVertex2f(this->width(),this->height());
glEnd();
glDisable(GL_TEXTURE_2D);
this->repaint = false;
}
}
Considerations:
As you can see, I work only with 2D images sized 1000x808 (fixed), and it shouldn't require too much power for rendering. I am currently coding this to work on Intel Core i3 Haswell machine (with integrated intel HD Graphics). On top a Linux Ubuntu 14.04 x64 OS, with latest intel drivers installed.
Expectation:
I expect to render/draw the images as soon as possible, without flickering. I have about 150 1000x808 images to render in a row (with ~12ms between images build process).
I would love to have a smooth ~60Hz smooth images being rendered on the screen
Questions:
Based on my code, what I need to do due to improve performance and stop flickering?
Is it really necessary to move to QOpenGLWidget other than current QGLWidget (deprecated?)?
As I have been written an OpenGL "immediate mode" code, Should I consider to move to VBO/PBO/VAO? And which one is best suitable for me?
Do I need linux tweaks due to improve performance? If so, what kind
of?
Any kind of help is very welcome!

Haxeflixel with Neko build, Screen size does not fit

I use Haxeflixel, choose build target Neko and Neko 64.
I coded 1280 x 720 resolution but executed screen is not fit.
change resoulution too.
I just reinstall my os x yosemite system. is the reason it?
I can not understand this situation
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
var initialState:Class<FlxState> = PlayState; // The FlxState the game starts with.
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
var framerate:Int = 60; // How many frames per second the game should run at.
var skipSplash:Bool = false; // Whether to skip the flixel splash screen that appears in release mode.
var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets
very default settings...
If I understand your question, the problem is that gameWidth and gameHeight set the game's logical screen size, not the size in pixels of the window that the game runs in.
Try changing the window settings in your project's Project.xml file to set the physical size of the window to match the game coordinates and it might start looking how you expect:
<!--These window settings apply to all targets-->
<window width="1280" height="720" fps="60" background="#000000" hardware="true" vsync="true" />
It's lime 2.4.4 problem.
download http://www.openfl.org/builds/lime/lime-2.4.0-6-g837aa96.zip
and
haxelib local lime-2.4.0-6-g837aa96.zip on terminal
see below..
http://community.openfl.org/t/running-openfl-error-on-mac/1409/14

How to disable snapview in WINJS?

I am creating an app in which snapview should be disabled.I have tried using:
window.addEventListener("resize", onViewStateChanged);
function onViewStateChanged(eventArgs) {
var viewStates = Windows.UI.ViewManagement.ApplicationViewState;
var newViewState = Windows.UI.ViewManagement.ApplicationView.value;
if (newViewState === 2 || newViewState===3) {
showMenu('snapped');
}
}
function showMenu(event) {
//Detect View State
if (event === 'snapped') {
var msg = new Windows.UI.Popups.MessageDialog(
"Resizing Window");
msg.showAsync();
window.innerWidth=screen.width
}
But this doesn't seem to work.Is there anything that i might have missed to disable the snapview.
Thanks
Because you're talking about snapped view, I assume that you're targeting Windows 8.0 and not Windows 8.1. In the latter, the snapped view state was removed in favor of variable-sized views, and in the app manifest you can indicate a minimum width of 500px (the default) or 320px (the former snapped view). Leaving it to 500px will prevent the narrow snapped view altogether.
If you are yet targeting Windows 8.0, there is unfortunately no means to disable snapped view (which is, by the way, why the change happened for 8.1). Apps that cannot effectively operate in the 320px view just display a message to that effect, suggesting to the user that they resize the view to use the app.

Image resizing using C#

The images that are fresh out from digital cameras are often above the size of 2-3 MB making it difficult for it to get transferred over email and other ways.
This requires the image to be resized (in terms of file size and not height or width). Quite similar to MS Paint offering image resizing functionality.
I am not well educated on image file theories. I would appreciate if someone can point me towards following information sources:
Image theory (how various image formats work jpeg, png, tiff etc).?
How does the image looses its sharpness when resized? Is there some
Are there any free .Net (I am using 4.0) libraries available for doing this? If not can I use any library using com interoperabilty?
Many thanks,
Image resizing is functionality is built right into the .NET framework. There are a couple of different approaches:
GDI+
WIC
WPF
Here's a nice blog post covering the differences between them.
Here's an example with GDI+:
public void Resize(string imageFile, string outputFile, double scaleFactor)
{
using (var srcImage = Image.FromFile(imageFile))
{
var newWidth = (int)(srcImage.Width * scaleFactor);
var newHeight = (int)(srcImage.Height * scaleFactor);
using (var newImage = new Bitmap(newWidth, newHeight))
using (var graphics = Graphics.FromImage(newImage))
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight));
newImage.Save(outputFile);
}
}
}
I used the example provided by Darin Dimitrov,
Image was inflated to and took up a lot of disk space (from 1.5MB to 17MB or so).
This is due to a small mistake in the last line of code.
The function below will save the image as Bitmap (huge image size).
newImage.Save(outputFile)
The correct function should be:
newImage.Save(outputFile, ImageFormat.Jpeg);
Imageresizer works well.
http://imageresizing.net/

Resources