How Center Vertical on Canvas

this my code

my canvas size y=291 X=84
g.Drawpicture newpic,(g.width-newpic.width)/2,(g.height-newpic.height/2)

but now work correct

That’s also not nearly enough of a snippet for anyone to know what’s wrong.
Please wrap code in [ code ] tags so it becomes formatted properly.

dim pic as new Picture(width, height, 32)

code=“12345”

barcode.barBackColor=self.barBackColor
barcode.code=self.code
barcode.barFontName=self.barFontName
barcode.barFontSize=self.barFontSize
barcode.barForeColor=self.barForeColor
barcode.barHeight=40
barcode.barType=self.barType
barcode.checkCharacter=self.checkCharacter
barcode.Code128Set=self.Code128Set
barcode.H=10
barcode.leftMargin=self.leftMargin
barcode.N=self.N
barcode.textOnTop=self.textOnTop
barcode.topMargin=self.topMargin
barcode.X=self.X
barcode.I=self.I
barcode.UPCEANSupplement2=self.UPCEANSupplement2
barcode.UPCEANSupplement5=self.UPCEANSupplement5
barcode.supplement=self.supplement
barcode.UPCESystem=self.UPCESystem

barcode.width=self.width
barcode.height=self.height

barcode.paintbarcode(pic.Graphics)
//barcode.paintBarcode(g)

dim min as integer

min=height
if (min>width) then min=width

dim newpic as new Picture(width,height, 32)
dim surf0 as RGBSurface = pic.RGBSurface
dim surf1 as RGBSurface = newpic.RGBSurface
dim x, y as Integer

for y = 0 to height - 1
for x = 0 to width - 1
surf1.Pixel(y, min - x) = surf0.Pixel(x, y)
next x
next

//g.DrawPicture(newpic,0,10+newpic.height/2)
g.Drawpicture newpic,(g.width-newpic.width)/2,(g.height-newpic.height/2)

//g.drawpicture mypic,(g.width-mypic.width)/2,(g.height-mypic.height/2)
//g.DrawPicture(newpic,0,0)

dim newpic01 as new Picture(width,height, 32)

Dim s as New StringShape
s.Text = “Hello World”
s.TextFont = “Helvetica”
s.Bold = True
s.Rotation =-3.14 /2
s.Y = 100
s.x=15
g.DrawObject(s)

That should work fine. What’s wrong with it? Is it possible the image in newpic isn’t centered, so therefore the result doesn’t look centered? Assuming newpic is created correctly, your code will center it precisely in the canvas, both vertically and horizontally.

Hi Tim

i have no more ideas how to fix it

where you think it should be my problem.

i have this working but no correct.

any help will be well appreciated.

Maybe better
g.Drawpicture newpic,(g.width-newpic.width)/2,(g.height-newpic.height)/2

LOL, good catch!

Thanks
I going to try

I have still problems with centralization

Is newpic exactly the size of the what you are putting into it? Is there white space to the left, right, above, or below it? Your code appears to be centering newpic on the canvas so if it is not centered to your eye at that time then it seems that what you are placing in newpic is not centered in it. If it is not centered then centering it on the canvas will not be centered visually

ok
thanks Harrie

Hi Thanks to all help.

https://drive.google.com/file/d/0B-0OCVXucD8CTzZiQ3dZRFdJUkE/edit?usp=sharing

Now i Need to Copy my Bar Code Canvas to Report Picture control can this be don