I am running on this issue where "every other" call on this function generates a "parameter not valid" error The private bitmap bitmapframmataphil (Metafile MF, Intel DPI, Graphics G) {int bitmapwdth = (int) (dpi * mf with / mf horriginal resolution); Int BitmapHight = (Int) (DPI * MF High / MF Vertical Resolution); G. Interpolation mode = Interpolation mode. Highquite bibbic; G. Sabooting mode = smoothing mode Antialysis; G.CompositingQuality = CompositingQuality.HighQuality; G.PixelOffsetMode = PixelOffsetMode.HighQuality; Bitmap BMP = new bitmap (bitmapwidth, bitmap-light, g); // This is an error line "parameter is not valid" g = graphics Framesize (bmp); G.Clear (Color.Transparent); G.DrawImage (MF, 0, 0, Bitmap width, BitMapHyight); Return BMP; }
Am I doing some coding which is causing some type of memory problem?
To provide more information, this is where it is being called:
Private Zero Generated Maps () {string tmpNameEMF = TempFileNameAndDelete () + " .emf "; String tmpNameEMFKeyMap = TempFileNameAndDelete () + "_keymap.emf"; Metafile mfTargetMap = Faucet; Metafile mfKeyMap = Faucet; Bitmap BM = new bitmap (1, 1); BM. Saturisolutions (Target IMGersution DPI, Target IMGrescription DPI); Try {if (TargetActiveMap! = Null) {using (Graphics gt = Graphics.FromImage (bm)) {gt.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; Gt. Interpolation mode = system Drawing Drawing 2D Interpolation mode Highquite bibbic; Gt.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; MfTargetMap = TargetActivap GetMapsAssetMail file (tmpNameEMF); Physical diagram = bitmapframmatafile (mfTargetMap, targetIMGRG resolution, DPI, GT); // if this is the call (OnTargetImgComplete! = Tap) OnTargetImgComplete (); }} If (KeyMapActiveMap! = Null) {Use (Graphics GK = Graphics. Framesize (BM)) {gk.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; Gk.InterolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; Gk.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; MfKeyMap = KeyMapActiveMap.GetMapAsMetafile (tmpNameEMFKeyMap); Mutated image_cammap = bitmapframmeta file (mfkmap, chemime imperialization dpi, gk); If (OnKeyMapImgComplete! = Tap) OnKeyMapImgComplete (); } Metized image_check = (bitmap) mfKeyMap.GetThumbnailImage ((int) physical contentimage_cmm.Wide * (mainmapmotionEmgSprint / 100), (int) physical contentimage_kimmap.hight * (keymapprintedMGSprint / 100), gatestream imageBeBort, Int.T.Zero); If (OnThumbnailImgComplete! = Tap) OnThumbnailImgComplete (); }} Hold (Exception Pre) {System.Windows.Forms.MessageBox.Show ("Error: CMImageToWord.GenerateMaps.1:" + East Message); } If (mfKeyMap! = Null) mfKeyMap.Dispose (); If (mfTargetMap! = Null) mfTargetMap.Dispose (); Try {File.Delete (tmpNameEMF); File.Delete (tmpNameEMFKeyMap); } Hold (Exception Pre) {System.Windows.Forms.MessageBox.Show ("Error: CMImageToWord.GenerateMaps.2:" + East. Message); }}
For a start, be sure that the bitmap is finally resolved and there is no way Metafile size and DPI negative values can be.
Comments
Post a Comment