Home > Software engineering >  Gdi DrawImage to abnormal call 2 times in a row
Gdi DrawImage to abnormal call 2 times in a row

Time:09-28

When m_image by Gdiplus: : Image: : FromStream (PSTM) access, call graphics. The DrawImage (m_pImage rcDst, l, nOffY nPartCX, nSrcCY, UnitPixel, pIA); Image right drawing to interface

But if again call graphics. DrawImage, draw failure, tip exception:


0 x740bb802 (KernelBase. DLL) (located in xx. Exe) caused by abnormal: 0 xc0000002: not running the operation of the request,,

To understand ~

CodePudding user response:

See if you need to shut down after use flow/close handle/release resources, etc

CodePudding user response:

Should not, if m_image come FromFile, continuous call many times are normal

CodePudding user response:

I guess, the flow need to adjust the flow of pos

CodePudding user response:

refer to the second floor utakeiteasy response:
should not, if m_image come FromFile, continuous call many times are normal


Stream has been closed after generating m_image cleared,
Image * m_image=Gdiplus: : Image: : FromStream (stream_);

M_image is new

CodePudding user response:

It seems I guessed it
Image. FromStream method (Stream) Visual Studio 2013 Visual Studio 2013

This article content has been translated by machine, if you connect to the Internet, please select "online check this topic" in the edit mode can be controlled English content to view this page,
Send feedback on this topic to Microsoft, online online check this topic in the default browser,


Create the Image from the specified data stream,


Namespace: System. Drawing
Assembly: System. Drawing (in the System. Drawing. DLL)
Syntax
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

JavaScriptC# c + + f # JScriptVB with colors to distinguish the format of the view is copied to the clipboard

Public static Image FromStream (
The Stream Stream
)

Public static Image FromStream (
The Stream Stream
)
Public:
The static Image ^ FromStream (
The Stream ^ Stream
)

Public:
The static Image ^ FromStream (
The Stream ^ Stream
)
The static member FromStream:
Stream: the stream - & gt; Image

The static member FromStream:
Stream: the stream - & gt; Image


'statement
Public Shared Function FromStream (_
The stream As the stream _
) As the Image

'statement
Public Shared Function FromStream (_
The stream As the stream _
) As the Image

Parameter
The stream
Type: System. IO. Stream
A Stream containing the Image data,

The return value
Type: System. Drawing. The Image
This method to create the Image,

Abnormal
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

An abnormal condition
ArgumentException the flow without effective image format

- or -

The stream is null,


Note
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

in the Image of the survival period, must make flow remain open,

If using the same flow continuous call this method, the flow will be reset to zero,


That description
A bitmap Image class does not support the Alpha transparency, to enable the Alpha transparency, please use 32 bits per pixel PNG images,


Version information
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

The.net Framework
Backed by the following version: 4.5, 4,3.5, 3.0, 2.0, 1.1, 1.0

The.net Framework Client Profile
Backed by the following version: 4,3.5 SP1

Platform
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Windows 8, Windows Server 2012 and Windows 7, Windows Vista SP2, Windows Server 2008 (does not support the Server core role), Windows Server 2008 R2 (SP1 or higher version of the Server with the core role; Do not support the Itanium)

CodePudding user response:

Associated with flow is close does, but why call time is normal?

M_image is dynamically generated, are generated, closed source data flow why there will be a problem?

CodePudding user response:

Why not use the Image: : Clone?

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

@ HDT

Reference the answer to your problem solved, the following are the main code

Gdiplus: : the Image * _image=nullptr;
HGLOBAL m_hMem=GlobalAlloc (GMEM_FIXED, code size ());//code is to store image data

BYTE * pmem=(BYTE *) GlobalLock (m_hMem);
Memcpy (pmem, & amp; Code [0], code. The size ());
GlobalUnlock (m_hMem);

Cost * PSTM;
CreateStreamOnHGlobal (m_hMem, TRUE, & amp; PSTM);
_image=Gdiplus: : Image: : FromStream (PSTM, FALSE);
,,,,,,

Graphics. DrawImage (_image, rcDest, 6, 6, 66, 66, Unit: : UnitPixel);
Graphics. DrawImage (_image, rcDest, 6, 6, 66, 66, Unit: : UnitPixel);

GlobalFree (m_hMem);//release the memory dynamic application (as long as the line after the DrawImage, many times it's no problem for me to call DrawImage)

CodePudding user response:

refer to 7th floor zhao4zhong1 response:
why not use Image: : Clone?


Program doesn't collapse, were I see from the output of

You said the Image of CLone don't know how to do

CodePudding user response:

Image: : Clone Method

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related