bitmap question
Moderator: DPlotAdmin
-
- Posts: 28
- Joined: Sat Jun 04, 2005 9:00 am
bitmap question
David,
can you tell me the number of pixels per inch that a bitmap is created with when i use DPlot_GetBitmapEx ?
i think i have my scaling problem solved once i know that.
thanks
jerry
can you tell me the number of pixels per inch that a bitmap is created with when i use DPlot_GetBitmapEx ?
i think i have my scaling problem solved once i know that.
thanks
jerry
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
Jerry,
A dpi setting in a bitmap is really meaningless until you draw the bitmap on the display, a printer, or whatever. Bitmaps can include a resolution setting (or not), but changing the value has no effect at all on the contents of the bitmap.
If the bitmap is drawn without any scaling then the "dpi" of the image is whatever the resolution of your output device is. My guess is you're using some strange VB gizmo that works with twips. Otherwise I'm not sure why you'd need to know the resolution. If you'll give me a bit more information on how you're drawing the bitmap then I can probably be a bit more help.
A dpi setting in a bitmap is really meaningless until you draw the bitmap on the display, a printer, or whatever. Bitmaps can include a resolution setting (or not), but changing the value has no effect at all on the contents of the bitmap.
If the bitmap is drawn without any scaling then the "dpi" of the image is whatever the resolution of your output device is. My guess is you're using some strange VB gizmo that works with twips. Otherwise I'm not sure why you'd need to know the resolution. If you'll give me a bit more information on how you're drawing the bitmap then I can probably be a bit more help.
Visualize Your Data
support@dplot.com
support@dplot.com
-
- Posts: 28
- Joined: Sat Jun 04, 2005 9:00 am
"strange VB gizmo"
that made me laugh, but twips do come into play, possibly.
here is what i am working on, i have been playing with it this morning,
if i plot using [ManualScale(1000,1000,2000,2000)] then the bitmap represents a section of the plane 1000 units wide and 1000 units high.
so i put that bitmap into a picturebox control set to 2880 twips, which should equal 2 inches, in height and width.
now if i read each pixel in the picture box i should be able to assign a scale value to that pixel which represents the location of its center within the plot. on my machine, if i make the picture box 2880x2880 twips (2x2 inches) then i get 192 x 192 pixels so the scale of each pixel is 1000/192 of a unit.
sounds simple, but its giving me trouble. the ultimate goal is to size my picture box so that one pixel is equal to one unit on the x and y axes of the original ManualScale (and thereby to one meter of distance on the surface of the earth). how i do that does not matter too much. once i have the scale i know how to "read" the color of each pixel and see if it is plack (therfore part of the contour) and i can send the coordinates of that pixel to a data file for further processing.
i'm drawing the bitmap into a picture box using your code from the btest2.vbp
i'll just keep expirementing,
any help would be great, but don't feel like you have to give me a private class in VB
cheers
jerry
that made me laugh, but twips do come into play, possibly.
here is what i am working on, i have been playing with it this morning,
if i plot using [ManualScale(1000,1000,2000,2000)] then the bitmap represents a section of the plane 1000 units wide and 1000 units high.
so i put that bitmap into a picturebox control set to 2880 twips, which should equal 2 inches, in height and width.
now if i read each pixel in the picture box i should be able to assign a scale value to that pixel which represents the location of its center within the plot. on my machine, if i make the picture box 2880x2880 twips (2x2 inches) then i get 192 x 192 pixels so the scale of each pixel is 1000/192 of a unit.
sounds simple, but its giving me trouble. the ultimate goal is to size my picture box so that one pixel is equal to one unit on the x and y axes of the original ManualScale (and thereby to one meter of distance on the surface of the earth). how i do that does not matter too much. once i have the scale i know how to "read" the color of each pixel and see if it is plack (therfore part of the contour) and i can send the coordinates of that pixel to a data file for further processing.
i'm drawing the bitmap into a picture box using your code from the btest2.vbp
i'll just keep expirementing,
any help would be great, but don't feel like you have to give me a private class in VB
cheers
jerry
-
- Posts: 28
- Joined: Sat Jun 04, 2005 9:00 am
I found this which may lead to a solution:
we'll see.
cheers
jerry
so i am going to try drawing into the picture box, then reading the twips per pixel, then redrawing the picture box to give a one pixel to one unit scale.Return the number of twips per pixel for an object measured horizontally (TwipsPerPixelX) or vertically (TwipsPerPixelY).
Syntax
object.TwipsPerPixelX
object.TwipsPerPixelY
The object placeholder represents anobject expression that evaluates to an object in the Applies To list.
we'll see.
cheers
jerry
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
Jerry,
Your problem is the picture box includes the entire graph, and the ManualScale entries are the extents of the axes and don't have a fixed relationship to the size of the entire bitmap (think numbers along the axes, axis titles, plot titles, etc.).
You'll probably be best off if you don't attempt to scale the bitmap to force it to fit in your picture box. Instead figure out the size in pixels of your picture box and then request a bitmap that size. Then the DPLOT_PLOTMETRICS structure in the call to DPlot_GetBitmapEx contains all the information you need to scale pixels to data space.
If I've misunderstood what you're trying to do please let me know.
Your problem is the picture box includes the entire graph, and the ManualScale entries are the extents of the axes and don't have a fixed relationship to the size of the entire bitmap (think numbers along the axes, axis titles, plot titles, etc.).
You'll probably be best off if you don't attempt to scale the bitmap to force it to fit in your picture box. Instead figure out the size in pixels of your picture box and then request a bitmap that size. Then the DPLOT_PLOTMETRICS structure in the call to DPlot_GetBitmapEx contains all the information you need to scale pixels to data space.
If I've misunderstood what you're trying to do please let me know.
Visualize Your Data
support@dplot.com
support@dplot.com
-
- Posts: 28
- Joined: Sat Jun 04, 2005 9:00 am
-
- Posts: 28
- Joined: Sat Jun 04, 2005 9:00 am
-
- Posts: 28
- Joined: Sat Jun 04, 2005 9:00 am
OK, David,
now that's the ticket. i've got what i need, i just need to check the pixels per inch of the picturebox on the form load event and then i can size the plot accordingly once the file to be plotted has been selected!
by the way on the way to get pizza i realized that i don't need to set the size to give at least one meter per pixel, rather i need at least one pixel per meter.
thanks again,
jerry
now that's the ticket. i've got what i need, i just need to check the pixels per inch of the picturebox on the form load event and then i can size the plot accordingly once the file to be plotted has been selected!
by the way on the way to get pizza i realized that i don't need to set the size to give at least one meter per pixel, rather i need at least one pixel per meter.

thanks again,
jerry
-
- Posts: 28
- Joined: Sat Jun 04, 2005 9:00 am
David,
i started to type another question:
This is so frustrating, every time i think its working and move on a new glitch comes in!
i'm sure you don't have that happen though.....
OK, here i am, using the plotmetrics works fine except that i can't get the scale to work quite right.
But then i had a thought, and solved the problem!
i am so happy i danced around the room, fortunately my wife is not home tonight
the thing that was hanging me up after i started to use the plotmetrics is the fact that Jr apparently was forcing a square output plot and when i drew that into the picture box it stayed square. that was throwing off the scale, though the plotmetrics were giving me the correct values they were way to far apart in x and too close together in y to be of use. i used the ContourScales(1,1,1) and now it works
it might be worth noting in the documentation that Jr will force a square plot??
i ended up getting ~1.5 meters between pixels so that should be fine, i can work on an improvement if the final output is not suitable.
now, on to the next step: writing the data to a compatible file.
cheers
jerry
i started to type another question:
This is so frustrating, every time i think its working and move on a new glitch comes in!
i'm sure you don't have that happen though.....
OK, here i am, using the plotmetrics works fine except that i can't get the scale to work quite right.
But then i had a thought, and solved the problem!
i am so happy i danced around the room, fortunately my wife is not home tonight



the thing that was hanging me up after i started to use the plotmetrics is the fact that Jr apparently was forcing a square output plot and when i drew that into the picture box it stayed square. that was throwing off the scale, though the plotmetrics were giving me the correct values they were way to far apart in x and too close together in y to be of use. i used the ContourScales(1,1,1) and now it works


it might be worth noting in the documentation that Jr will force a square plot??
i ended up getting ~1.5 meters between pixels so that should be fine, i can work on an improvement if the final output is not suitable.
now, on to the next step: writing the data to a compatible file.
cheers
jerry
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
Actually that's a user option: Options>General>Always auto-adjust scale factors on 3D plots that, as you've already found out, you can override with [ContourScales()]....the fact that Jr apparently was forcing a square output plot ...
Visualize Your Data
support@dplot.com
support@dplot.com