locked
Image in image RRS feed

  • Question

  • User790345666 posted

    Hi,

    I have a project where clients viewing my website can buy t-shirts. They can choose from a number of t-shirt colors and shapes which are their plain colour.

    They can also choose a number of prints to be placed on the t-shirt. These will be graphics stored in a database. My problem is on how I can displaty the t-shirt with the graphics or logo they chose on te t-shirt.

    It would be something like drawing text on an image but instead drawing an existing image on the base image.

    Any Ideas?

    (I am using visual studio 2005 and vb.NET)

     

    Regards

    Wednesday, June 21, 2006 12:13 PM

All replies

  • User2128074059 posted

    1. You can create a blank image with the same size of the orginal image, such as T-shirt image.

    2. Draw the t-shirt image on the new image from step 1.

    3. Draw your favourite graphics or logo on the image from step 2.

    Tuesday, July 11, 2006 11:16 PM
  • User-1681532974 posted

    This is just a snippet of code for what I think you are attempting to do.  You will need to modify it to get it to work for you.  Hope it helps.

    'show img2 interposed on the primary img

    Dim logoScaling As String = Request.QueryString("ls")

    If logoScaling = "" Then

    logoScaling = "1"

    End If

    Dim logo As Bitmap

    Dim background As Image

    Dim g1 As Graphics

    Dim g2 As Graphics

    background = Image.FromFile(Server.MapPath("images/catalog/full/" & img))

    logo = Image.FromFile(Server.MapPath("_resources/uploads/images/" & img2))

    'find the logoscaling based on its size in relation to the background image

    Dim backgroundHeight As Integer = background.Height

    Dim backgroundWidth As Integer = background.Width

    Dim logoHeight As Integer = logo.Height * logoScaling

    Dim logoWidth As Integer = logo.Width * logoScaling

    Dim scaledLogo As New Bitmap(logo, logoWidth, logoHeight)

    Dim scaledLogoStream As New MemoryStream()

    Using (scaledLogoStream)

    scaledLogo.Save(scaledLogoStream, ImageFormat.Png)

    End Using

    Dim backgroundStream As New MemoryStream()

    Using (backgroundStream)

    background.Save(backgroundStream, ImageFormat.Png)

    End Using

    g1 = Graphics.FromImage(background)

    g2 = Graphics.FromImage(scaledLogo)

    g2.SmoothingMode = SmoothingMode.AntiAlias

    g1.DrawImage(scaledLogo, Convert.ToSingle(backgroundWidth - logoWidth), Convert.ToSingle(backgroundHeight - logoHeight))

    'g1.SmoothingMode = SmoothingMode.AntiAlias

    Dim stmMemory As New MemoryStream()

    Using (stmMemory)

    Response.Clear()

    Response.ContentType = "image/png"

    background.Save(stmMemory, ImageFormat.Png)

    stmMemory.WriteTo(Response.OutputStream)

    Response.End()

    End Using

    background.Dispose()

    Thursday, July 20, 2006 4:03 PM
  • User790345666 posted

    Hi Oinkage, I tried it out and it worked out fine.

    Cheeres [:)]

    Friday, July 21, 2006 2:25 AM