DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

bitmap question

 
Post new topic   Reply to topic    DPlot Forum Index -> Basic
View previous topic :: View next topic  
Author Message
walleye3313



Joined: 04 Jun 2005
Posts: 28

PostPosted: Fri Mar 10, 2006 11:15 am    Post subject: bitmap question Reply with quote

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
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri Mar 10, 2006 11:37 am    Post subject: Reply with quote

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.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
walleye3313



Joined: 04 Jun 2005
Posts: 28

PostPosted: Fri Mar 10, 2006 12:31 pm    Post subject: Reply with quote

"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
Back to top
View user's profile Send private message
walleye3313



Joined: 04 Jun 2005
Posts: 28

PostPosted: Fri Mar 10, 2006 12:48 pm    Post subject: Reply with quote

I found this which may lead to a solution:

Quote:
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.



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.

we'll see.

cheers
jerry
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri Mar 10, 2006 12:56 pm    Post subject: Reply with quote

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.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
walleye3313



Joined: 04 Jun 2005
Posts: 28

PostPosted: Fri Mar 10, 2006 12:59 pm    Post subject: Reply with quote

OK,

i'll take a look at that, i think you understand just what i'm trying to do.

thanks
jerry
Back to top
View user's profile Send private message
walleye3313



Joined: 04 Jun 2005
Posts: 28

PostPosted: Fri Mar 10, 2006 1:08 pm    Post subject: Reply with quote

On a quick glance i think i see how this works.

I will try it out after lunch, if i can get (wx,wy) in this way then i'm home free and i only need to scale the bitmap large enough to give at least one meter per pixel.

thanks, pizza time....

jerry
Back to top
View user's profile Send private message
walleye3313



Joined: 04 Jun 2005
Posts: 28

PostPosted: Fri Mar 10, 2006 7:01 pm    Post subject: Reply with quote

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. Embarassed

thanks again,
jerry
Back to top
View user's profile Send private message
walleye3313



Joined: 04 Jun 2005
Posts: 28

PostPosted: Fri Mar 10, 2006 10:17 pm    Post subject: Reply with quote

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 Very Happy Very Happy Very Happy

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 Very Happy Very Happy

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
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Sat Mar 11, 2006 1:02 am    Post subject: Reply with quote

Quote:
...the fact that Jr apparently was forcing a square output plot ...


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()].
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> Basic All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group