Rank: Newbie
Groups: Registered
Joined: 12/4/2017(UTC) Posts: 9  Location: Bratislava
|
Hello, I have an issue with disposing PdfBitmap. It seems to disposing PdfBitmap corrupt memory. On the last line app throws System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'. When I remove pdfBitmap dispose (avoiding using), it works. I'm using 3.11.3.2704 version, but I tried it also on newest version. Code:using (var pdfBitmap = new PdfBitmap(width, height, true))
{
pdfBitmap.FillRect(0, 0, width, height, Color.White);
this.pdfPage.Render(pdfBitmap, 0, 0, width, height, PageRotate.Normal, RenderFlags.FPDF_LCD_TEXT);
Bitmap = (Bitmap)pdfBitmap.Image.Clone();
}
// this throws System.AccessViolationException
Bitmap.Save(@"D:\test.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
Can you help me with it? Thank you
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi, Please use Code:
Bitmap = new Bitmap(pdfBitmap.Image);
instead of Clone(). The System.Drawing.Image.Clone() method creates a new Bitmap object but the pixel data is shared with the original bitmap object. The Bitmap(Image) constructor also creates a new Bitmap object but one that has its own copy of the pixel data. More details can be found here: https://stackoverflow.co...one-and-new-bitmapbitmap
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 12/4/2017(UTC) Posts: 9  Location: Bratislava
|
Super, it works. Thank you.
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close