A null reference or invalid value was found [GDI+ status: InvalidParameter] - asp.net-mvc-3

I am running an MVC3 app on Mono/linux and everything is working fine with the exception of an image upload utility. Whenever an image upload is attempted i get the Invalid Parameter error from within the method below:
System.Drawing.GDIPlus.CheckStatus(status As Status) (unknown file): N 00339
System.Drawing.Bitmap.SetResolution(xDpi As Single, yDpi As Single)
I've googled this error extensively and have found that the Invalid parameter error can often be misleading, and could fire if for example there was an error with the upload itself, or if the image was not fully read. This runs fine on IIS/Windows, but I've not been able to get it to work in Mono.
Apache2
Mono 2.10.8.1
Am i missing something simple or do i need to find a different way to handle image manipulation for mono?

After doing quite a bit of testing, I was able to determine the root of my error. I was attempting to use the Image.HorizontalResolution and Image.VerticalResolution properties for Bitmap.Resolution . While these properties were set on the initial upload (where the file is read into a stream from the tmp directory), when i posted back with the base64 encoded string of the image itself, it appears these values were lost somehow. Because of this the SetResolution method failed.
For whatever reason i do not have this issue on IIS/Windows, the properties exist in both circumstances.

I encountered a similar issue. A Bitmap loaded from disk, reported bmp.HorizontalResolution==0 and bmp.VerticalResolution==0 when they were both==300. This behaviour does not occur on Windows.
A bit more digging, I found that the following test fails:
[Test]
public void GDI_SetResoltion()
{
var b1 = new Bitmap (100, 100);
Assert.That (b1.HorizontalResolution, Is.Not.EqualTo (0));
Assert.That (b1.VerticalResolution, Is.Not.EqualTo (0));
}
I believe Windows will default resolution to 96 dpi.

Related

GetManifest() and GetThumbnail() fail on some Item Version of Forge Model Derivative API

I'm using Forge c# client library to read A360 hub/project/folders structure using a 3legged token (Model Derivative API).
For every [Version] of a [Item] in [Data Service] of A360 i need to know:
if a file has conversion errors;
if it has a thumbnail, get it;
if a item version is ready show it in the viewer (using viewer v.
2.xx)....
After authentication, i correctly see the users account hub-project-folders structure:
A360Hub
---Samples
------Golden Bridge Gate.dwf
---------Golden Bridge Gate.dwf (v1)
------V8 Engine.iam
---------V8 Engine.iam (v1)
When i call the GetManifest() using [Golden Bridge Gate.dwf (v1)] urn i get the expected result:
string strGoldenBridgeGateV1_urn (v1) urn1 = "dXJuOmFk......_dmVyc2lvbj0x";
....
DerivativesApi.GetManifest(strGoldenBridgeGateV1_urn)->OK
DerivativesApi.GetThumbnail(strGoldenBridgeGateV1_urn)->OK
....
When i call the same code using [V8 Engine.iam (v1)] urn i get "Error 404: not found".
....
string strV8EngineIamV1_urn="dXJuOmFkc2su........Gc_dmVyc2lvbj0x";
DerivativesApi.GetManifest(strV8EngineIamV1_urn)->FAIL (404)
DerivativesApi.GetThumbnail(strV8EngineIamV1_urn)->Fail (404)
....
Error details:
-------------- Exception:
Error code:404
HResult:-2146233088
Stack:
Autodesk.Forge.Client.ApiException: Error calling GetThumbnail: in
Autodesk.Forge.DerivativesApi.GetThumbnailWithHttpInfo(String urn,
Nullable`1 width, Nullable`1 height) in
Autodesk.Forge.DerivativesApi.GetThumbnail(String urn, Nullable`1
width, Nullable`1 height) in my code...
Same happens on file with other files: it works with .RVT,.DWF files;
it fails with .IAM, .NWC, .SLDASM, .IFC files....
Any idea?
For A360 files the translation is already there, you don't need to use Derivative API, unless you need to convert to a different format (RVT -> IFC, for instance).
Update: Data Management API was released in mid-2016 and old files on old accounts, specially those sample files, need to be recreated for it to work. Workaround (for sample files) is to download and upload again to a different folder. Customer data was migrated.
Take a look at this sample, is shows the viewable if available (check this line too).

Getting the filename/path from MvvmCross Plugins.DownloadCache

I'm currently using MvvmCross DownloadCache -- and it's working alright -- especially nice when I just need to drop in an Image URL and it automagically downloads / caches the image and serves up a UIImage.
I was hoping to leverage the code for one other use case -- which is I'd like to grab source images from URL's and cache the files on the local file system, but what I really want for this other use case is the image path on the local file system instead of the UIImage itself.
What would help me most if I could get an example of how I might accomplish that. Is it possible to make that happen in a PCL, or does it need to go into the platform specific code?
Thanks -- that works, but just in case anyone else is following along, I wanted to document how I got the Mvx.Resolve<IMvxFileDownloadCache>() to work. In my setup.cs (in the touch project), I had:
protected override void InitializeLastChance ()
{
Cirrious.MvvmCross.Plugins.DownloadCache.PluginLoader.Instance.EnsureLoaded();
Cirrious.MvvmCross.Plugins.File.PluginLoader.Instance.EnsureLoaded();
Cirrious.MvvmCross.Plugins.Json.PluginLoader.Instance.EnsureLoaded();
...
}
But that wasn't enough, because nothing actually registers IMvxFileDownloadCache inside the DownloadCache plugin (which I was expecting, but it's just not the case).
So then I tried adding this line here:
Mvx.LazyConstructAndRegisterSingleton<IMvxFileDownloadCache, MvxFileDownloadCache>();
But that failed because MvxFileDownloadCache constructor takes a few arguments. So I ended up with this:
protected override void InitializeLastChance ()
{
...
var configuration = MvxDownloadCacheConfiguration.Default;
var fileDownloadCache = new MvxFileDownloadCache(
configuration.CacheName,
configuration.CacheFolderPath,
configuration.MaxFiles,
configuration.MaxFileAge);
Mvx.RegisterSingleton<IMvxFileDownloadCache>(fileDownloadCache);
...
}
And the resolve works okay now.
Question:
I do wonder what happens if two MvxFileDownloadCache objects that are configured in exactly the same way will cause issues by stepping on each other. I could avoid that question by changing the cache name on the one I'm constructing by hand, but I do want it to be a single cache (the assets will be the same).
If you look at the source for the plugin, you'll find https://github.com/MvvmCross/MvvmCross/blob/3.2/Plugins/Cirrious/DownloadCache/Cirrious.MvvmCross.Plugins.DownloadCache/IMvxFileDownloadCache.cs - that will give you a local file path for a cached file:
public interface IMvxFileDownloadCache
{
void RequestLocalFilePath(string httpSource, Action<string> success, Action<Exception> error);
}
You can get hold of a service implementing this interface using Mvx.Resolve<IMvxFileDownloadCache>()
To then convert that into a system-wide file path, try NativePath in https://github.com/MvvmCross/MvvmCross/blob/3.2/Plugins/Cirrious/File/Cirrious.MvvmCross.Plugins.File/IMvxFileStore.cs#L27

JavaCV IplImage.createFrom hangs in place

Not sure why this is happening. The method :
IplImage.createFrom(image);
Is hanging without returning any value. I've tried multiple images, and confirmed their existence. I'm writing an application that harnesses template matching, however this initial step is giving me a headache. Does anyone know why this method would suspend the thread and not return any value? I've done some research, and confirmed my OpenCV path is set up, and that all my libraries are properly setup.
Before converting a BufferedImage to iplimage we need to create an iplimage which has same height and width as the BufferedImage. Try this code:
IplImage ipl_image = IplImage.create(buffered_image.getWidth(),buffered_.getHeight(),IPL_DEPTH_8U,1);
ipl_image = IplImage.createFrom(buffered_image);

blobstore images get_serving_url

I am new to the Google App Engine and I am trying to use the Blobstore to store images that I want to display later on.
The image storage works fine. Now I want to dynamically change some images in my html code. Therefore I need a method of getting the images out of the blobstore and passing them. I am using Python. I found the get_serving_url-command, which seemed to be the perfect fit. Sadly, this causes an Error and I seem to be unable to fix it.
My basic code looks like this:
blob_key = "yu343mQ7kT4344N434ewQ=="
if blob_key:
blob_info = blobstore.get(blob_key)
if blob_info:
img = images.Image(blob_key=blob_key)
url = images.get_serving_url(blob_key)
...
Everytime the function gets called, I get the following Error in my Log Console.
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py",
line 234, in _MakeRealSyncCall
raise pickle.loads(response_pb.exception())
AttributeError: 'ImagesNotImplementedServiceStub' object has no
attribute 'THREADSAFE'
I have no idea how to fix it or if I am doing something terribly wrong.
I am very grateful for your support! Thank you in advance!
Have a nice day
You probably need an instance of BlobKey so if you are getting blob_info successfully try:
img = images.Image(blob_key=blob_info.key())
url = images.get_serving_url(blob_info.key())

StackID Api issue

I downloaded the StackID api from the following link http://code.google.com/p/stackid/source/checkout
I followed the instructions in the readme file but am still encountering an exception.
The site crashes on this line in the Current.cs file
private static string SiteWideSalt { get { return KeyStore.GetKey(KeyStore.LatestKeyVersion).Salt; } }
The error I'm receiving is:
The type initializer for 'OpenIdProvider.Helpers.KeyStore' threw an exception.
{"Error converting value 1 to type 'OpenIdProvider.Helpers.KeyStore+Key'."} <--this is what's in the inner exception, which to me doesn't make sense since the property for value is byte and last I checked this should work with the number 1.
Any help would be appreciated, thanks!
I also had some issues there.
After putting the content of the key-gen file in square brackets "[]" to make it a JSON array I had to restart IIS and it works fine now.

Resources