Sorry, Parameter is not valid - c#-2.0

I'm exporting some data to PDF. The data contains one or more bitmaps.
Unfortunately I'm getting the following error during the export.
Sorry, Parameter is not valid.
Source:
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Image original, Int32 width, Int32 height)
Type: System.ArgumentException
Any help will be highly appreciable.
Regards,
Maruthi Kumar

Related

Cannot save a non-current version - Umbraco 8

I'm having a problem with saving content programmatically, I click a link on an email message and I'm taken to the site, on this occasion, the CMS is updated. But if I click the link again I get the following error:
Cannot save a non-current version
" at Umbraco.Core.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent entity)\r\n
at Umbraco.Core.Cache.DefaultRepositoryCachePolicy`2.Update(TEntity entity, Action`1 persistUpdated)\r\n
at Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase`2.Save(TEntity entity)\r\n
at Umbraco.Core.Services.Implement.ContentService.<>c__DisplayClass57_0.<CommitDocumentChangesInternal>g__SaveDocument|2(IContent c)\r\n
at Umbraco.Core.Services.Implement.ContentService.CommitDocumentChangesInternal(IScope scope, IContent content, ContentSavingEventArgs saveEventArgs,
IReadOnlyCollection`1 allLangs, Int32 userId, Boolean raiseEvents, Boolean branchOne, Boolean branchRoot)\r\n
at Umbraco.Core.Services.Implement.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId, Boolean raiseEvents)\r\n
at Web.Controller.Controllers.ContactController.CoachConfirmed(String id)
The code is below
var contentService = Services.ContentService;
var content = contentService.GetById(new Guid(coachDocType));
content.SetValue("numberOfTrainees", newNumberOfSpaces);
content.SetValue("numberOfTraineesFollowing", newNumberOfSpacesTaken);
contentService.SaveAndPublish(content);
In V7, I use to be able to do ApplicationContext.Current.Services.ContentService.RePublishAll();, but V8 does not seem to have that option anymore
Any help would be appreciated
George
Seems this is a bug in Umbraco, as per https://github.com/umbraco/Umbraco-CMS/issues/2997 and fix will be rolled out in version 8.3.0

Size of the uploaded image using multipart form data in Web API

Not able to get the size of the uploaded image using the multipart form data in web api C#.
I have used the code provided on the following website:
https://yogeshdotnet.com/web-api-2-file-upload-asp-net-mvc/
dataitem.Headers.ContentDisposition.FileName
"\"TEST.png\""
dataitem.Headers.ContentDisposition.Size
null
dataitem.Headers.ContentDisposition
{form-data; name="test_image"; filename="TEST.png"}
CreationDate: null
DispositionType: "form-data"
FileName: "\"TEST.png\""
FileNameStar: null
ModificationDate: null
Name: "\"test_image\""
Parameters: Count = 2
ReadDate: null
Size: null
size is null here. I want the size of the image. I ran this code in the immediate window.
HttpPostedFile file = HttpContext.Current.Request.Files["test_image"];
//size of the image in bytes.
int size = file.ContentLength;
This helped me to get the size of the image.

Is MetroCriteriaId an integer or a string?

The Google documentation for the GeoPerformance report is a little confusing. On the one hand it says that MetroCriteriaId is of Type Integer but in the Notes it says Name of the metro as a string.
Do anyone know which one is correct, or do I just suck it and see?
It doesn't seem to matter what it is, Int or String, as even in 80812-line report the field is empty. The report definition I used is below and I got data for everything except MetroCriteriaId. Dead field? No idea.
<reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201406">
<selector>
<fields>AccountCurrencyCode</fields>
<fields>AccountDescriptiveName</fields>
<fields>AccountTimeZoneId</fields>
<fields>AdFormat</fields>
<fields>AdGroupId</fields>
<fields>AdGroupName</fields>
<fields>AdGroupStatus</fields>
<fields>AdNetworkType1</fields>
<fields>AdNetworkType2</fields>
<fields>AverageCpc</fields>
<fields>AverageCpm</fields>
<fields>AveragePosition</fields>
<fields>CampaignId</fields>
<fields>CampaignName</fields>
<fields>CampaignStatus</fields>
<fields>CityCriteriaId</fields>
<fields>Clicks</fields>
<fields>Conversions</fields>
<fields>Cost</fields>
<fields>CostPerConversion</fields>
<fields>CostPerConversionManyPerClick</fields>
<fields>CountryCriteriaId</fields>
<fields>Ctr</fields>
<fields>CustomerDescriptiveName</fields>
<fields>Date</fields>
<fields>DayOfWeek</fields>
<fields>Device</fields>
<fields>ExternalCustomerId</fields>
<fields>Impressions</fields>
<fields>IsTargetingLocation</fields>
<fields>LocationType</fields>
<fields>MetroCriteriaId</fields>
<fields>Month</fields>
<fields>MonthOfYear</fields>
<fields>MostSpecificCriteriaId</fields>
<fields>PrimaryCompanyName</fields>
<fields>Quarter</fields>
<fields>RegionCriteriaId</fields>
<fields>ValuePerConversion</fields>
<fields>ValuePerConversionManyPerClick</fields>
<fields>ViewThroughConversions</fields>
<fields>Week</fields>
<fields>Year</fields>
<dateRange>
<min>20140601</min>
<max>20140630</max>
</dateRange></selector>
<reportName>Custom Geo Performance Report</reportName>
<reportType>GEO_PERFORMANCE_REPORT</reportType>
<dateRangeType>CUSTOM_DATE</dateRangeType>
<downloadFormat>TSV</downloadFormat>
</reportDefinition>

Type conversion with Boost Generic Image Library

I currently have an image of the type boost::gil::rgb8c_view_t. I need to pass it to a function with this prototype:
void function(const boost::gil::rgb8c_view_t& input, const int index, const boost::gil::rgb8c_view_t::view_t &output)
I have created an output image by using the following syntax:
boost::gil::rgb8c_view_t::view_t output(input._dynamic_cast<boost::gil::rgb8c_view_t::view_t>());
At this point, the compiler accepts the image output as input for the function. However, I need the image back to the boost::gil::rgb8c_view_t type. The question is:
Is it a correct way to allocate the image output?
How do I transform it back to the type boost::gil::rgb8c_view_t?
Thank you in advance,
NĂ©stor
I am not sure if I understand your question correctly (see comments above), but to create an output image with the same size as your input image, you could use a call like the following:
boost::gil::rgb8_image_t output_image(input.dimensions());
And get a mutable view like this:
boost::gil::rgb8_view_t boost::gil::view(output_image);
Of course you can also get a constant/immutable view like this:
boost::gil::rgb8c_view_t boost::gil::const_view(output_image);

How to set error correction level for QR code when using the new createbitmap method

This question is in reference to the API documentation link, http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/barcodelib/BarcodeBitmap.html
They specify that the old method
public static Bitmap createBitmap(ByteMatrix byteMatrix,
int maxBitmapSizeInPixels)
is deprecated.
But by using the new method,
public static Bitmap createBitmap(ByteMatrix byteMatrix)
they haven't specified a way to specify the error correction level for the QR code in Multiformatwriter. I haven't been able to find a way either, looking through various member functions.
Has anyone tried this?
Thanks for your help.
Here is my code, and I have checked with my phone, the error correction level is set correctly according to my phone.
Hashtable hints = new Hashtable();
switch (comboBox1.Text)
{
case "L":
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
break;
case "Q":
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q);
break;
case "H":
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
break;
default:
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
break;
}
MultiFormatWriter mw = new MultiFormatWriter();
ByteMatrix bm = mw.encode(data, BarcodeFormat.QR_CODE, size, size, hints);
Bitmap img = bm.ToBitmap();
pictureBox1.Image = img;
When encoding, you can pass in hints
Map<EncodeHintType, Object> hints = new Hastable<EncodeHintType, Object>();
Add the error correction setting to the hints (for example to level M)
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
ZXing uses error correction level L by default (the lowest, meaning the QR Code will still be readable even after a max of 7% damage)
Just looked to the documentation.
It says to use createBitmap(ByteMatrix byteMatrix) in conjunction with MultiFormatWriter. That has method encode(String contents, BarcodeFormat format, int width, int height, Hashtable hints) where you could specify width, height and error level.
To specify error level put to hints hashtable key EncodeHintType.ERROR_CORRECTION with value new Integer(level).
Unfortunately I didn't find any constants for these values as described here. but probably you could find it in axing sources.

Resources