drawimage with imagelout.center

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts Page 1 of 1
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

drawimage with imagelout.center
Dummy1912
Hello,

yep another problem :lol:

just hope this will be solved.

it seems we can't paint a image with imagelayout.center (this is because as default the backgroundimagelayout = center)
so we need to use that part to resize the backgroundimage with paint

i made a custom picturebox
and i want to use 2 images
1 at background with imagelayout center
and 1 image

the image works fine
but i still need to make this background to work

our code:
Code: Select all
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim G As Graphics = e.Graphics
        G.Clear(Color.White)
        MyBase.OnPaint(e)
        G.DrawImage(Me.BackgroundImage, 0, 0, ImageLayout.Zoom, ImageLayout.Zoom)
    End Sub
result:
see image
no image has been showed only the image i added
but no backgroundimage :(

anyone?
thanks
You do not have the required permissions to view the files attached to this post.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: drawimage with imagelout.center
XTechVB
When you override the System Paint always delete this
Code: Select all
MyBase.OnPaint(e)
That's just the default paint message, but since you're doing the drawing yourself, you don't need it.
You can find me on Facebook or on Skype mihai_92b
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

#XTechVB,

i removed it but now i don't get any image :?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: drawimage with imagelout.center
XTechVB
Dummy1912 wrote:
#XTechVB,

i removed it but now i don't get any image :?
You are inheriting the PictureBox base class aren't you? :lol:
I don't really understand what you are trying to do, can you be more specific? :?
You can find me on Facebook or on Skype mihai_92b
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

well not really
Code: Select all
    Inherits PictureBox

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim G As Graphics = e.Graphics
        G.Clear(Color.White)
        'MyBase.OnPaint(e)
        G.DrawImage(Me.BackgroundImage, 0, 0, ImageLayout.Zoom, ImageLayout.Zoom)
    End Sub
i want to paint the backgroundimage with the settings backgroundimagelayout = zoom
because when i paint the image with
Code: Select all
G.DrawImage(Me.BackgroundImage, 0, 0, width, height)
if fills out the complete background
and i want to use the default backgroundimagelayout = zoom
to set the size.

i can't explain it in any other way if you still don't get it :?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

My idea is that: i think that the backgroundimage cannot be seen because there's an image above it which is the image that you see.

try to empty the image for the main time just to see if the background image
is there. :(
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

yes #noypikami
when i remove the image no background image has been showed.
only it will be showed when i use:
Code: Select all
            G.DrawImage(Me.BackgroundImage, 0, 0, width, height)
instead of
Code: Select all
            G.DrawImage(Me.BackgroundImage, 0, 0, ImageLayout.Zoom, ImageLayout.Zoom)
but i want to set the size automatic with the picturebox backgroundimagelayout.zoom
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: drawimage with imagelout.center
XTechVB
When BackgroundImage Property is set then the PictureBox draws the selected image automatically, why are you drawing it again manually?
Code: Select all
 G.DrawImage(Me.BackgroundImage, 0, 0, ImageLayout.Zoom, ImageLayout.Zoom)
If you want to draw two images in one PictureBox, then use two custom Image type properties, that way you have full control over what is drawn and how, without any interference from the PictureBox.

But i think you'll be better off using a custom control, that way you have control over everything.
Inheriting and modifying existing controls is always a bad idea.
You can find me on Facebook or on Skype mihai_92b
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

seems it has no point of asking
because we don't get far :lol:

i just want my own picturebox with some round corners as you can see on the image
but i can't set the backgroundimage with the same backgroundimagelayout
and i want this so it fits the image as ZOOM with drawimage
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

nvm got it sloved.
Code: Select all
        G.DrawImage(me.BackgroundImage, 0, 15, 188, 188)

its a nice result
thanks anyway for the help #XTechVB ;)
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
10 posts Page 1 of 1
Return to “Coding Help & Support”