6 Replies - 635 Views - Last Post: 16 February 2015 - 05:18 PM Rate Topic: -----

#1 ZakaryHansen   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 28-February 14

Is it possible to color a backgroundimage?

Posted 16 February 2015 - 03:06 PM

I've got the main form set with a background image, and I have panels that I'd put components to modify data and whatnot in.
Normally, I'd photoshop an image with that panel size to make the panel appear to have colored the main form.

So it would go from this:(panel1.backcolor set)Posted Image
to this:(*photoshopped)Posted Image


Is it possible to do this via coding? All I do in photoshop is change the Hue by a certain amount, it seems like it should be possible to do this automatically with coding.

This thread allows you to change color to an extent, but it replaces all pixels with a monotone color rather than modifying the hue.

This post has been edited by ZakaryHansen: 16 February 2015 - 03:22 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Is it possible to color a backgroundimage?

#2 ZakaryHansen   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 28-February 14

Re: Is it possible to color a backgroundimage?

Posted 16 February 2015 - 03:52 PM

Oh, I've also tried setting a layer's property in Photoshop to "color" and saving with hopes that it would work similar to transparency. It did not. ha
Was This Post Helpful? 0
  • +
  • -

#3 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1503
  • View blog
  • Posts: 3,801
  • Joined: 01-February 13

Re: Is it possible to color a backgroundimage?

Posted 16 February 2015 - 03:56 PM

Hi,

It almost looks like the image in your photoshop image has had the hue changed in some sort of a pattern or with some other effect used too. Just changing the hue of a solid colored image should make the whole image change to that same solid color.

Unless your original image was not a single solid color to begin with. Maybe i am wrong but, i am guessing that there was some other effects used in photoshop to make a pattern look to the image.

Anyways, CodeProject has an example project you could check out that is used for changing the hue at the link below.

Hue Saturation Lightness Filter

There are probably more examples around the net too.
Was This Post Helpful? 0
  • +
  • -

#4 ZakaryHansen   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 28-February 14

Re: Is it possible to color a backgroundimage?

Posted 16 February 2015 - 04:24 PM

Sorry for the confusion, the first picture provided was a panel over the backgroundimage with the backcolor set to the color I'd like to change the background to. The background itself has the pattern.
Was This Post Helpful? 0
  • +
  • -

#5 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1503
  • View blog
  • Posts: 3,801
  • Joined: 01-February 13

Re: Is it possible to color a backgroundimage?

Posted 16 February 2015 - 04:38 PM

Oh...Ok. So, the image is the form`s background image and you want to make the panel`s BackColor partially transparent so the background image can be seen through it?
Was This Post Helpful? 0
  • +
  • -

#6 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1503
  • View blog
  • Posts: 3,801
  • Joined: 01-February 13

Re: Is it possible to color a backgroundimage?

Posted 16 February 2015 - 05:06 PM

No mater if the Image is the BackgroundImage of the Form or the Panel then you can do that using the Panels Paint event. The only difference is that if it is the Form`s BackgroundImage then you will need to set the Panel`s BackColor to Transparent and just choose the Color you want for the Panel in the Paint event.

If it is the Panel`s BackgroundImage then you can use the Panel`s BackColor to choose the color you use in the Paint event.

In this example i showed both. The top panel is just transparent and the red color is set in Panel1`s Paint event. Panel2 has a BackgroundImage and i set the BackColor of it to red.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Panel1.BackColor = Color.Transparent
        Panel2.BackColor = Color.Red
    End Sub

    Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        Using sb As New SolidBrush(Color.FromArgb(180, Color.Red)) '180 is the transparency of the color Min=0 Max=255
            e.Graphics.FillRectangle(sb, 0, 0, Panel1.ClientSize.Width, Panel1.ClientSize.Height)
        End Using
    End Sub

    Private Sub Panel2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint
        Using sb As New SolidBrush(Color.FromArgb(180, Panel2.BackColor)) '180 is the transparency of the color Min=0 Max=255
            e.Graphics.FillRectangle(sb, 0, 0, Panel2.ClientSize.Width, Panel2.ClientSize.Height)
        End Using
    End Sub
End Class



Attached Image
Was This Post Helpful? 0
  • +
  • -

#7 ZakaryHansen   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 28-February 14

Re: Is it possible to color a backgroundimage?

Posted 16 February 2015 - 05:18 PM

Not see through, perse. I want it to change the hue. The link you provided seems like it would work great, so I'll play with it a bit and see if I can find out how to integrate it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1