constructing a bitmap from stream rotates the image - asp.net

I am using ASP.Net with VB and doing some file uploads. Sometimes, when a bitmap is constructed from the file input stream, the image gets rotated. It doesn't seem to happen if the image is wider than it is tall, but also doesn't seem to happen all the time if the image is taller than wide. I have provided a few screen shots where the properties of the image are show, and the created bitmap's properties are shown at run time.
Any ideas what is happening here or what we can do to prevent this rotation?
Rotated image:
Non-rotated image:

Using the rotation code found Here fixed it. The images were coming from a phone camera and had original orientation information stored in them that could be used to right them.

Related

QPainter drawImage becomes very pixelated

I use QPainter and the function drawImage to draw an airplane on a map. The image and redrawn each time the position of the airplane changes. The problem is, after some time, the image becomes extremely pixelated. I have tried to use a high quality .svg and that did not help either.
Below is my code. Can somebody spot where the error is or what has caused the image to be so pixelated?
// Load .svg image
airplane->load("AirplaneTopDown.svg");
// Downsize image
airplaneSmall = airplane->scaled(120, 120,Qt::KeepAspectRatio);
// Rotate image by trans
airplaneSmall = airplaneSmall.transformed(trans);
// Draw image and center at a certain screen position
painter.drawImage(airplaneX-airplaneSmall.width()/2,airplaneY-airplaneSmall.height()/2,airplaneSmall);
Below are the images of the drawn airplanes. One taken as screenshot at the beginning of the program runtime another one taken after a couple of minutes.
Airplane
Airplane-pixelated
One of your problems is that you first rescale the image and then rotate it.
The rotation needs to interpolate new pixels from the old ones. The higher the resolution of the input, the better the quality of the interpolation. The quality of your SVG is completely lost after the rescale operation.
The second problem you are facing is that you use the "fast" (default) transformation method. This method does not antialias. So instead of interpolating from several input pixels, it will only take one best fit. Calling transformed() with the second argument Qt::SmoothTransformation and scaled() with the sceond argument Qt::SmoothTransformation |Qt::KeepAspectRatio` will greatly improve your results.
However it is also slower, as is performing the rotation on the image in its original, higher resolution.
The arguably best solution to your problem is to take on a different approach. Instead of loading the SVG into a QImage, which is a raster-based image, you should work with the vector graphics. So the SVG is rendered in the right orientation and scale in the first place. A good starting point is the SVG Viewer Example: http://doc.qt.io/qt-5/qtsvg-svgviewer-example.html

Mediawiki Images no resize

How can I force mediawiki to disable resizing and use the original size of my image? My main problem is that I'm uploading small parts of screenshots. If I don't use the original size then they look awful. (Imagine a 237px wide image resized to 400px....) But I don't see any option for that.
http://www.mediawiki.org/wiki/Help:Images#Size_and_frame
By simply using the image name, it will fit the image to screen which is really bad! For example, a 300px wide screenshot cutout looks awful on a full hd monitor... You could say that the image may be too large for the users' screen but in my particular case that is not the case. I'll always be using small images (300px and smaller) and the users will always watch these pages on desktop monitors.
I'm sorry I was very dump. If I don't use any option then it is displayed in its original size. I was mistaken because somebody has changed the zoom level of my browser, but I did not realize this because the monitor resolution was so high...

QImage loads with wrong orientation for certain images

I am instantiating a QImage from an image file like below and subsequently rendering it on a QWidget.
QImage ( const QString & fileName, const char * format = 0 )
For most images, everything works fine. But for a few images, the QImage gets loaded with a 90-degree rotated image.
It seems this happens only with pictures taken earlier on my phone in portrait mode. Those taken in landscape are fine
You might need to use a library like libexif to determine the photo orientation and then rotate the QImage accordingly
Since Qt 5.5 set Image.autoTransform : true because the default is false!
QT Image QML Type reference
With C++ Qt-class QImageReader:
QImageReader imgReader( imagePath );
imgReader.setAutoTransform( true );
QImage img = imgReader.read();
https://discussions.apple.com/thread/2541504?start=0&tstart=0
It sounds like it is a pretty common issue, where there is some flag or tag added on the image that says how to rotate it, instead of actually reordering the pixels in the image. For the image you are trying to render, you could go and take the format you are trying to use, and see if there are any extra flags you could check and have Qt do the rotation.
Sounds like cppguy knows of a library that can let you check these flags.
EDIT Found a better description for it:
johninsj - Re: iPhone 4 Photo's & Video Rotating Sideways In Email
Nov 2, 2010 1:45 PM (in response to VibrantRedGT)
Apple sets the jpeg meta tag for orientation when you shoot a photo,
so if you hold the iphone upside down, or sideways, etc, the image
(which is shot upside down or sideways, since the camera is upside
down/sideways) knows it needs to flip/rotate the image when you look
at it.
Not all software honors the rotation settings. Gimp (which runs on
everything, and is free) does.
You can rotate images and save them, or learn to shoot photos with the
iPhone in the correct orientation for non-rotated images. That would
be with the home button to the right as you look at the screen.
Hope that helps.

Why UIImageView moves from its original place (interface builder) during runtime?

I have placed 3 images into UIImageViews using xcode4 interface builder: background, and two pictures. Background image fills the whole visible area and it looks the same in interface builder, in simulator and on device. In addition, I'm placing another image at the very bottom (stick to) of visible area, and another one on top of it. Both looks as I want in interface builder. The problem is both bottom image and on top of bottom image moves approximately by 50 pixels up when running in simulator or iphone4 device. Interesting part is that background image fill whole visible area. I should note that I'm using UIInterfaceOrientationLandscapeRight orientation so the status bar in my orientation should appear on top but I have disabled it in plist, so I guess it's not related to this problem. Both of my problematic UIImageView's have mode "Bottom". Also, all of three images have #2x image twin. But why can see everything OK in interface builder and then some shift on simulator and device? Also, strange why background is not moved. Does anybody had the same problem?
Try hiding all elements in your nib. (status bar, tool bar, etc)
Make sure you have your springs adjust for your desired effect.
Hope this helps!

Saving large images created in Flex

I am attempting to capture a very large image that was made dynamically within the Flash Player (the size of the image is 2400px by 12,000px) and am running into some very serious issues... Let me run down how the image get's to that size in the first place:
User adds elements to a canvas and then when the user is finished the canvas scales up to 2400px wide and ~12,000px tall. The problem arises when I attempt to save the image to the hard drive. Now, I dont know if this will affect the recommended fix, but the rendered image wont be saved on the hard drive, it will be sent to a server. I know about the ~4050px limit in Flash Player and was thinking I could get around that by clipping the images with the ImageSnapshot.captureBitmapData() method and keeping the required Rectangle variable below 4000px then repeat that down the large image until it reaches the end where the final images will be pieced together at a later time. However... As i mentioned the error comes when it reaches the 'fileReference.save(pngImage);' method... Has anyone else done something like this?
Have you tried if fileReference.save works at all (e.g. with smaller images like 100 px height)? It seems that the image data will perhaps be transformed to string data, so there might be other limits you're not aware of at the moment (your uncompressed image data will be around 86 MB, so even a PNG file with good compression might be around 10 MB in size, at the moment you're trying to save a third of this, but 3 MB still is quite large).

Resources