Jump to content
Developer Wiki and Function Reference Links ×

Texture width/height


Recommended Posts

Hi,

Can somebody help me? I need to read the width and height values of the bitmap image in the "color" family of a texture. What am I doing wrong?

htexture:=getobject(texturename); {texture handle OK I get it}

hshader:=getshaderrecord(htexture,1); {shader handle for "color" OK I get it}

hbitmap:=gettexturebitmap(hshader); {bitmap handle of shader OK I get it}

width:=GetObjectVariableLongInt(hbitmap,530); {return zero}

height:=GetObjectVariableLongInt(hbitmap,531); {return zero}

Thanks, sorry for my english!

Link to comment

Are your handles valid at each step? If one of them returns NIL (0) then all subsequent commands will not work.

You can check your handles with this statement placed after your code unless you are inside a Modern Dialog handler routine.

message('texture = ', htexture, ' shader = ', hshader, ' bitmap = ', hbitmap);

If your handles all have non-zero values, then you can check that the type of the last handle is indeed a bitmap with:

message('handle type = ', GetType(hbitmap));

It should return 14 for a bitmap. I haven't tried what you are doing, so I'm not sure if it will work the way you are headed.

HTH,

Raymond

PS - Thank you for your English. My Italian couldn't hold a candle to your English.

Link to comment

Thanks Raymond,

you're right! For hbitmap I get "93"=texture.

Now I'm a bit confused: description of "gettexturebitmap" function is:

"Function GetTextureBitmap returns the bitmap object attached to the referenced texture."

but it returns a texture (93). So what is the function that really returns the bitmap?

Thanks Miguel,

before writing this post I tried with GetObjectVariableInt function too but nothing changed.

Here:

http://developer.vectorworks.net/index.php?title=VS:Function_Reference_Appendix

I can read to use GetObjectVariableInt

In my local VectorScript 2012 Function Reference I can read to use ObjectVariableLongint

Link to comment

It's the one I wrote in the first post:

hbitmap:=gettexturebitmap(hshader); {bitmap handle of shader OK I get it}

that returns type 93 (texture) instead 14 (bitmap) using GetType(hbitmap).

I need to understand why, or a valid function to get width and height from a texture.

Link to comment

Ah, so it is. How quickly I forget.

I'm not sure I know what dimension you are looking for; texture size before or after it's applied. If it's the size of the texture before it's used, I get some numbers with:

BitSize := GetTexBitFeatureSize(hbitmap);

GetTexBFeatureStart(hbitmap, X1, Y1);

GetTexBFeatureEnd(hbitmap, X2, Y2);

message(BitSize, ' - ', X1, ', ', Y1, ' - ', X2, ', ', Y2);

BitSize is in inches, but the units of the other numbers, your guess may be better than mine.

Raymond

Link to comment

I'm looking for the dimensions (in pixels) of the image used to create the texture.

To understand better:

I'm updating my "Arredo" plugin to create framed pictures/mirrors, and I need to know the width and height of the image to automatically set the height of the object.

For example, if an user create a texture using a picture of 800x600 pixels, I will calculate totalheight:=totallength*(600/800).

Thanks for your patience :)

Link to comment
  • 2 years later...

So i'm running into the same issues. Not really sure what this image texture (93) is or how that relates to a bitmap (14).

I'm trying to go the other way, from a bitmap to a texture. I want to grab existing bitmaps from the drawing (not bring up a dialog box that asks to locate an image). Can't seem to figure it out.

Link to comment
I'm looking for the dimensions (in pixels) of the image used to create the texture.

Does your PIO apply Bitmaps or Textures?

If the latter, it seems to me that you actually need the size of the Texture you're applying. GetObjectVariablereal(TextureHandle,511) will give you the width (in real-world dimensions) of the Texture. (I use this one quite a bit to determine Texture scaling.)

If Raymond's recommendation of using GetTexBFeatureStart and GetTexBFeatureEnd will work on the Texture's handle (I've never given this a try) you could get the Texture's aspect from its pixel starting and ending points and calculate height based on that and the above GetObjectVariablereal dimension.

Does that help, at all?

Link to comment

Hi Andrew,

I need "paint width" and "paint height" of the color shader (bitmap) of the texture (pixel size). On VS:Function_Reference_Appendix I found the function that I need: ObjectVariableLongint(530) and ObjectVariableLongint(531) but I can't make them work.

I got handle of texture map, handle of color shader and finally handle of "texturebitmap" but I can't get pixel dimensions of that texturebitmap.

htexturemap:=getobject(texturename); {object type=97-Texture Definition (Material)}

hshader:=getshaderrecord(htexturemap,1); {get color shader handle}

htexture:=gettexturebitmap(hshader); {object type=93-Texture}

message(getobjectvariableint(htexture,530)); {should return pixel size but doesn't work}

Can you help me?

Thanks

Link to comment
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...