Comment puis-je analyser un polyligne record métafichier d'un tableau d'octets?
Question
Je besoin d'un peu d'aide pour définir le type suivant de Windows GDI en C #. J'ai les données sous la forme d'un byte[]
en C #, et je dois maréchal en quelque sorte ou jeté comme suit dans C #. Je suppose que je dois définir la structure appropriée? Ceci est le type:
NOM
META_POLYLINE
API CALL NEAREST
#include <windows.h>
BOOL32 Polyline
(
HDC32 hdc,
const POINT32 *pt,
INT32 count
);
DESCRIPTION
U16 array no Value --------------------------- -------------- 0 no of points 1 each odd until the end x of the point 2 each even until the end y of the point
Une polyligne est une liste de points. Contrairement à un polygone, polyligne est toujours non rempli, et peut être ouvert.
La solution
byte[] buffer;
fixed (byte* b = buffer)
{
ushort* ptr = (ushort*)b;
int count = (int)*ptr;
var points = new Point[count];
for (int i = 0; i < count; i++)
{
int x = (int)*(++ptr);
int y = (int)*(++ptr);
points[i] = new Point(x, y);
}
}
(non testé)
Autres conseils
Avez-vous regardé entrée Polylignes PInvoke.net encore?
D'accord, un record pour un métafichier polyligne ... Vous pouvez essayer de faire un Buffer.BlockCopy
à partir du tableau d'octets à un réseau de UInt16
.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow