AFDesign Posted May 4, 2012 Share Posted May 4, 2012 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! Quote Link to comment
MullinRJ Posted May 4, 2012 Share Posted May 4, 2012 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. Quote Link to comment
Miguel Barrera Posted May 5, 2012 Share Posted May 5, 2012 Could it be that the function should be intVar:= GetObjectVariableInt(hbitmap,530); as listed in the VS appendix rather than a longint variable. Quote Link to comment
AFDesign Posted May 5, 2012 Author Share Posted May 5, 2012 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 Quote Link to comment
MullinRJ Posted May 6, 2012 Share Posted May 6, 2012 I use ObjectVariableLongint() in Reshaper to get the size of bitmaps and it works. I guess I didn't read the online developer reference. One of them is obviously wrong. I'm not sure how to extract the underlying bitmap from a texture. Raymond Quote Link to comment
MullinRJ Posted May 6, 2012 Share Posted May 6, 2012 After a quick scan through the html VSFuncRef I found the function GetTextureBitmap ( shaderRecord :HANDLE ) :HANDLE; Have you tried it? I'm not sure if it will work, as I've never used it. Good luck, Raymond Quote Link to comment
AFDesign Posted May 6, 2012 Author Share Posted May 6, 2012 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. Quote Link to comment
MullinRJ Posted May 7, 2012 Share Posted May 7, 2012 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 Quote Link to comment
AFDesign Posted May 7, 2012 Author Share Posted May 7, 2012 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 Quote Link to comment
Justin Smith Posted May 24, 2014 Share Posted May 24, 2014 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. Quote Link to comment
C. Andrew Dunning Posted May 26, 2014 Share Posted May 26, 2014 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? Quote Link to comment
AFDesign Posted May 26, 2014 Author Share Posted May 26, 2014 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 Quote Link to comment
C. Andrew Dunning Posted May 26, 2014 Share Posted May 26, 2014 Sorry, Andrea, the pixel size calls aren't some I've used and, due to vacation, won't be able to do any tinkering with them for several days. Quote Link to comment
AFDesign Posted May 27, 2014 Author Share Posted May 27, 2014 No problem thank you again and have a good vacation! Quote Link to comment
Carles Olle Posted October 26, 2016 Share Posted October 26, 2016 On 5/26/2014 at 1:01 AM, AFDesign said: getobjectvariableint(htexture,530) Did you ever get this to work? Quote Link to comment
Recommended Posts
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.