CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    [RESOLVED] Hot to have a transparent background in an ownerdrawn picture

    I need to set a picture in a background which is painted ownerdrawn using a LinearGradientBrush. In the picture the background should exactly show the gradient changeing colors of the other background, so my figure looks like directly being drawn into the GradientBackground When I create the picture ( icon ) with microangelo and having the backgroundcolors as being transparent, I dont get the background in the same way as the rest of the background is. In the moment I do something like
    Code:
    protected override void OnPaint(PaintEventArgs pe)
    {
    Graphics g = pe.Graphics;
    .....
    // Drawing the Background
    LinearGradientBrush b = new LinearGradientBrush(rec, startColor, endColor, 90);
    g.FillRectangle(b, rec);
    ...
    // drawing the picture
    Rectangle srcRect = new Rectangle(new Point(0, 0), _HeaderPicture.Size); 
    g.DrawImage(_HeaderPicture, destRect, srcRect, g.PageUnit); 
    ...
    But this looks as if it doesnt really have a transparent background but only one Color of my Gradient brush in the full background area

    How to do this correct, or do i need to draw the full Icon myself too ?
    Drawing each dot, which is not transparent myself too?
    In this case my question is how to read out the color data of an icon pixel by pixel and how to paint each single pixel ?

    Jonny Poet
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  2. #2
    Join Date
    Nov 2002
    Location
    Baby Land
    Posts
    646

    Re: Hot to have a transparent background in an ownerdrawn picture

    I don't know if I understand your question correctly but perhaps you can use something like in this example here
    http://www.bobpowell.net/transcontrols.htm

  3. #3
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Hot to have a transparent background in an ownerdrawn picture

    Quote Originally Posted by Luthv
    I don't know if I understand your question correctly but perhaps you can use something like in this example here
    http://www.bobpowell.net/transcontrols.htm
    That comes near to the point to draw the icon myself So anyone knows how to read out Icon data and how to draw a pixel in a specific color so I can do a loop reading a point and if it hasn't transparent color then drawing the picel in its color.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  4. #4
    Join Date
    Nov 2002
    Location
    Baby Land
    Posts
    646

    Re: Hot to have a transparent background in an ownerdrawn picture

    If you only want to draw icon with its transparent background then why not use DrawIcon method instead of DrawImage?

  5. #5
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Hot to have a transparent background in an ownerdrawn picture

    Quote Originally Posted by Luthv
    If you only want to draw icon with its transparent background then why not use DrawIcon method instead of DrawImage?
    works thx
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured