- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 poUnbuffered 选项时,TVirtualStringTree 中的 PaintTree 逻辑似乎存在错误。只有树的第一个节点在输出中可见。我使用最小 VST 示例进行了测试,行为是相同的。当 poUnbuffered 用作选项时,只有第一个节点可见,删除该选项并且树将被正确绘制。
如果我单步执行代码,那么所有对象都会被绘制在 Canvas 上,因此看起来像是剪切问题,但我没有充分使用 VST 来确定问题所在。他们对 Canvas 原点和剪裁进行了很多尝试。
要查看问题的实际情况,只需将以下代码放在任何包含 VST 的表单上,根据需要更改名称以保护无辜者,然后单击即可。
procedure TMainForm.Button2Click(Sender: TObject);
var
saveBitmap: TBitmap;
begin
saveBitmap := TBitmap.Create;
try
saveBitmap.height := 400;
saveBitmap.width := 400;
vst.PaintTree(
saveBitmap.Canvas,
Rect(0, 0, 400, 400),
Point(0, 0),
[poBackground, poColumnColor, poGridLines, poUnbuffered], // Remove poUnbuffered to have the tree paint correctly
pfDevice // pixelformat
);
saveBitmap.SaveToFile('E:\temp\CanvasSave' + FormatDateTime('hhnnsszzz', Now) + '.bmp');
finally
saveBitmap.Free;
end;
end;
有人遇到过这种情况吗?
更多详细信息:
poUnbuffered 和没有 poUnbuffered 的绘制代码之间几乎没有什么区别。我没有使用列,所以主要区别是:
if not (poUnbuffered in PaintOptions) then
begin
// Create small bitmaps and initialize default values.
// The bitmaps are used to paint one node at a time and to draw the result to the target (e.g. screen) in one step,
// to prevent flickering.
NodeBitmap := TBitmap.Create;
// For alpha blending we need the 32 bit pixel format. For other targets there might be a need for a certain
// pixel format (e.g. printing).
if MMXAvailable and ((FDrawSelectionMode = smBlendedRectangle) or (tsUseThemes in FStates) or
(toUseBlendedSelection in FOptions.PaintOptions)) then
NodeBitmap.PixelFormat := pf32Bit
else
NodeBitmap.PixelFormat := PixelFormat;
NodeBitmap.Width := PaintWidth;
// Make sure the buffer bitmap and target bitmap use the same transformation mode.
SetMapMode(NodeBitmap.Canvas.Handle, GetMapMode(TargetCanvas.Handle));
PaintInfo.Canvas := NodeBitmap.Canvas;
end
else
begin
PaintInfo.Canvas := TargetCanvas;
NodeBitmap := nil;
end;
和
if not (poUnbuffered in PaintOptions) then
begin
// Adjust height of temporary node bitmap.
with NodeBitmap do
begin
if Height <> PaintInfo.Node.NodeHeight then
begin
// Avoid that the VCL copies the bitmap while changing its height.
Height := 0;
Height := PaintInfo.Node.NodeHeight;
SetCanvasOrigin(Canvas, Window.Left, 0);
end;
end;
end
else
begin
SetCanvasOrigin(PaintInfo.Canvas, -TargetRect.Left + Window.Left, -TargetRect.Top);
ClipCanvas(PaintInfo.Canvas, Rect(TargetRect.Left, TargetRect.Top, TargetRect.Right,
Min(TargetRect.Bottom, MaximumBottom)))
end;
稍后有一些 BitBlt 在不使用 poUnbuffered 时将位图复制到 Canvas 。
最佳答案
这是我从另一个有关 PaintTree 代码和 poUnbuffered 的问题中发现的问题的解决方法。我上面列出的第二个代码摘录显然存在问题。显然 SetCanvasOrigin 正在更改原点,而 ClipCanvas 没有考虑这些更改。代码应更改如下:
begin
SetCanvasOrigin(PaintInfo.Canvas, -TargetRect.Left + Window.Left, -TargetRect.Top);
// ClipCanvas(PaintInfo.Canvas, Rect(TargetRect.Left, TargetRect.Top, TargetRect.Right,
// Min(TargetRect.Bottom, MaximumBottom)))
ClipCanvas(PaintInfo.Canvas, Rect(0, 0, TargetRect.Right - TargetRect.Left,
Min(TargetRect.Bottom - TargetRect.Top, MaximumBottom - TargetRect.Top)));
end;
我已经验证这在我的情况下有效。它可能不适用于所有情况。在我的情况下,我只使用 poUnbuffered,因此我的风险是有限的。
关于delphi - 使用 poUnbuffered 时 TVirtualStringTree 中的 PaintTree 行为不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22055775/
使用 poUnbuffered 选项时,TVirtualStringTree 中的 PaintTree 逻辑似乎存在错误。只有树的第一个节点在输出中可见。我使用最小 VST 示例进行了测试,行为是相同
我是一名优秀的程序员,十分优秀!