i have direct2d demo creates gridpatternbitmapbrush draws grid pattern on tform in paint method. how direct2d gridpatternbitmapbrush appear on tcximage.canvas( developerexpress timage) insead of form?
procedure tformadvgeometries.create_fradialgradientbrush; var // agradientstops: array of td2d1gradientstop; // agradbrushprops: td2d1radialgradientbrushproperties; // agradstopscollection: id2d1gradientstopcollection; gradcolors: array of tcolor; begin setlength(gradcolors, 3); gradcolors[0] := tcolor($00d7ff); // gold (d2d1helper.h) gradcolors[1] := tcolor($00a5ff); // orange (d2d1helper.h) gradcolors[2] := tcolor($0045ff); // orangered (d2d1helper.h) // place-holder. // code below assumes equal spread positions in gradient stops fradialgradientbrush := d2dcanvas.createbrush( gradcolors, d2d1pointf(330, 330), d2d1pointf(140, 140), 140, 140 ); end; procedure tformadvgeometries.create_fgridpatternbitmapbrush; var gridbrush: id2d1solidcolorbrush; bmpbrushprops: d2d1_bitmap_brush_properties; bitmaprendertarget: id2d1bitmaprendertarget; bmpsize: d2d_size_f; gridbitmap: id2d1bitmap; begin bmpsize.width := 10; bmpsize.height := 10; d2dcanvas.rendertarget.createcompatiblerendertarget( @bmpsize, nil, nil, 0, bitmaprendertarget); bitmaprendertarget.createsolidcolorbrush( d2d1colorf(0.93, 0.94, 0.96, 1), nil, gridbrush); bitmaprendertarget.begindraw; bitmaprendertarget.fillrectangle(rect(0, 0, 10, 1), gridbrush); bitmaprendertarget.fillrectangle(rect(0, 0, 1, 10), gridbrush); bitmaprendertarget.enddraw; bitmaprendertarget.getbitmap(gridbitmap); bmpbrushprops.extendmodex := d2d1_extend_mode_wrap; bmpbrushprops.extendmodey := d2d1_extend_mode_wrap; bmpbrushprops.interpolationmode := 0; // 1 d2dcanvas.rendertarget.createbitmapbrush( gridbitmap, @bmpbrushprops, nil, fgridpatternbitmapbrush); end; procedure tformadvgeometries.createdeviceresources; begin create_fradialgradientbrush; create_fgridpatternbitmapbrush; end; procedure tformadvgeometries.paint; var defmatrix: td2dmatrix3x2f; begin inherited; createdeviceresources; d2dcanvas.begindraw; try d2dcanvas.rendertarget.gettransform (defmatrix); // fill white color whole window d2dcanvas.rendertarget.clear(d2d1colorf(clwhite)); // fill canvas little blue rectangles d2dcanvas.brush.handle := fgridpatternbitmapbrush; d2dcanvas.rectangle(0, 0, clientwidth + 50, clientheight + 50); // reset standard transformation d2dcanvas.rendertarget.settransform (defmatrix); d2dcanvas.enddraw; end; end;
you need change constructor of d2dcanvas.
currently it's
d2dcanvas := tdirect2dcanvas.create(handle);
which passing forms handle create canvas.
i don't have delphi 2010 (which seems shipped required units demo) think
d2dcanvas := tdirect2dcanvas.create(mytcximage.canvas.canvas, rect(0,0, mytcximage.width,mytcximage.height));
should trick
you'll need pass canvas.canvas constructor because cx components (at least version of) use tcxcanvas contains tcanvas.
you may able pass window handle of tcximage control direct2dcanvas constructor.
Comments
Post a Comment