PDA

View Full Version : Getting/Setting Pixels...


Kickflipkid687
11-27-2010, 09:15 PM
Hello,

I've seen the other posts on here about this, and used them to start this little script. But... I'm definitely not doing the math right or something, because although the pixel count isn't terribly off, it's still off.

If you run this code on a Unwrapped mesh, you will get the 1st number printed, which is the empty space between the UV Shells in pixel count, then the last number printed is what is what's set in the new bitmap as the pixel count.

Anyone know how I could fix this to be accurate? I'm sure doing my floor method is part of it.


(
local theSelection = selection[1]

if selection.count == 1 then
(
setCommandPanelTaskMode #modify;
modPanel.addModToSelection (Unwrap_UVW ())
local theUnwrapMod = modPanel.getCurrentObject()

theUnwrapMod.renderuv_width = 128 -- integer; Width
theUnwrapMod.renderuv_height = 128 -- integer; Height
theUnwrapMod.renderuv_force2sided = false -- boolean; Force_2_Sided
theUnwrapMod.renderuv_fillColor = (color 255 255 255) -- RGB color; Fill_Color
theUnwrapMod.renderuv_fillalpha = 1.0 -- float; Fill_Alpha
theUnwrapMod.renderuv_fillmode = 1 -- integer; Fill_Mode
theUnwrapMod.renderuv_showoverlap = true -- boolean; Overlap
theUnwrapMod.renderuv_overlapColor = (color 255 255 255) -- RGB color; Overlap_Color
theUnwrapMod.renderuv_edgeColor = (color 255 255 255) -- RGB color; Edge_Color
theUnwrapMod.renderuv_edgealpha = 1.0 -- float; Edge_Alpha
theUnwrapMod.renderuv_visibleedges = false -- boolean; Visible_Edges
theUnwrapMod.renderuv_invisibleedges = false -- boolean; Invisible_Edges
theUnwrapMod.renderuv_seamedges = false -- boolean; Seam_Edges
theUnwrapMod.renderuv_seamColor = (color 255 255 255) -- RGB color; Seam_Color
theUnwrapMod.renderuv_showframebuffer = true -- boolean; Show_Frame_Buffer

--Render to Max Root Dir or TurboTools Dir
theUnwrapMod.unwrap5.renderUV "C:\Users\MATT\Desktop\New folder (2)\wtf.jpg"

local theUVBitmap = openBitMap "C:\Users\MATT\Desktop\New folder (2)\wtf.jpg"

local arr = #();
for i = 0 to theUVBitmap.width do join arr (for f = 0 to theUVBitmap.height where (getPixels theUVBitmap[i,f] 1)[1] == color 0 0 0 collect [i,f] )
close theUVBitmap

local wastedSpaceBit = bitmap 128 128
print arr.count

test = sqrt (arr.count)
test2 = floor test
print test2

local counter = 0

for i = 0 to test2 do
(
for f = 0 to test2 do
(
setPixels wastedSpaceBit [i,f] #(color 255 255 255)
counter+=1
)
counter+=1
)

print counter
display wastedSpaceBit
)
)

Thanks!

CGTalk Moderation
11-27-2010, 09:15 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.