Re: GDI Plus library

new topic     » goto parent     » topic index » view thread      » older message » newer message
LewisTownsend said...

Thanks Pete, The flat array doesn't seem to work either. That does make the most sense tho and it was the first thing I tried. I am tying my brain into knots trying to use pointers to pointers. Here is a simplified version that still doesn't work. Is this using the "(flat) array of 32-bit floats"?

It looks like you're trying to wrap this function:

Status DrawPolygon(       
    const Pen *pen, 
    const PointF *points, 
    INT *count 
); 

The PointF class actually contains 2 REALs. According to GdiPlusTypes.h, a REAL is a float, which is a 32-bit floating point number. The array of PointFs is identical to a flat array of 'x' and 'y's. In C/C, a pointer to something is more or less how those languages deal with arrays. You can then manipulate the pointer to get array-like behavior. So all we have to do is store them sequentially in memory (which you were doing, except in the wrong form).

Also, count is actually a pointer to an int. Try this:

global procedure DrawLinePolygon(atom p_graphics,atom p_pen, sequence points ) 
	-- points is a 1-dimensional sequence in the form of {x1,y1,x2,y2,x3,y3...} 
	atom status, p_points 
	integer count 
	sequence floats 
	count = length(points)-- count is the number of x and y values 
	p_points = allocate( (count+1)*4 )-- allocate 4 bytes per integer 
	poke4( p_points, count ) 
	floats = {} 
	for i = 1 to count do 
		floats &= atom_to_float32( points[i] ) 
	end for 
	poke( p_points + 4, floats ) 
 
	--(GpGraphics *graphics,GpPen *pen,GDIPCONST GpPointF *points,INT count) 
	if gdiplus>0 then 
		status = c_func(xGdipDrawPolygon,{p_graphics, p_pen, p_points+4, p_points}) 
	end if 
 
	puts(1, GetErrorString(status) & "\t" & sprint(points) & "\n" ) 
	free( p_points ) 
end procedure 

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu