DATA_3DR Not using entire picturebox

Q&A for Visual Basic, Visual Basic .NET, and PowerBasic developers using DPlot

Moderator: DPlotAdmin

Post Reply
xander_P
Posts: 10
Joined: Mon Sep 11, 2006 9:23 am

DATA_3DR Not using entire picturebox

Post by xander_P »

I recently upgraded my copy of DPLOT from 2.1.0.5 to 2.1.1.8 and noticed an unfortunate side effect (for me at least) in doing so. It appears that when displaying a plot using the DATA_3DR data format the generated plot doesn't fill up the entire picturebox anymore. At least it appears that way on my current setup.

The easiest way to understand, I believe, is to try the BTEST2 sample project you provide with the DPLOTLIB. In the 2.1.0.5 version pressing the "gridded data" button followed by the "random data" button produces the following result (basically the random data plot completely covers the previous plot):
http://s14.photobucket.com/albums/a337/ ... OT2105.jpg

In the 2.1.1.8 version when I follow the same steps it appears as though the plot doesn't generate wide enough and as a result gets anchored to the left side of the plot, thus not completely covering the previous plot:
http://s14.photobucket.com/albums/a337/ ... ot2118.jpg

So is there anyway (new command?) I can get the new version to react the same way as 2.1.0.5 version? Should I start to look for ways to counteract this new result in my program? Could the problem be specific to my computer? Note its not the failure to cover the previous plot that is my concern, its more that it doesn't completely fill the picturebox, and is no longer centered in the picturebox.

Any help is appreciated. :D
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

That's an unintended side effect of a recent change that, by default, removes most white space from bitmaps. Unfortunately the new [SetImageCrop()] command has no effect on bitmaps retrieved with any of the DPLOTLIB functions, only on bitmaps saved to disk. I'll fix this oversight in the next release, sorry for the trouble.

In the meantime about all you can do is erase the interior of the destination rectangle before drawing the bitmap. In the btest2 demo's Picture1_Paint routine, add

ret = FillRect(hdc, rcPic, GetStockObject(WHITE_BRUSH))

anywhere after "hdc = GetDC(Picture1.hwnd)" and before the BitBlt line.

If it's important to you that the bitmap is centered in the destination rectangle then you'll also need to make use of the bitmap dimensions retrieved with GetObject:

Dim dx, dy As Long

ret = GetObject(hBitmap, Len(bm), bm)
dx = (rcPic.Right - rcPic.Left - bm.bmWidth) / 2
dy = (rcPic.Bottom - rcPic.Top - bm.bmHeight) / 2

ret = BitBlt(hdc, rcPic.Left + dx, rcPic.Top + dy, ....
Visualize Your Data
support@dplot.com
xander_P
Posts: 10
Joined: Mon Sep 11, 2006 9:23 am

Post by xander_P »

Thanks for looking into it. And thanks for the advice on centering the plot in the meantime. :D
Post Reply