Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2003, 02:50 AM
Authorized User
 
Join Date: Jun 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default combining two images

I have an image that gets uploaded I want to take this image and put it on a background image and then save it as a new image I can't figure out how to do it.

Thanks
 
Old December 8th, 2003, 10:33 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Take a look at the System.Drawing classes. In there is the Image class. This is a windows bitmap. You can create a new Image from a file (of many formats) or an IO stream (like what you would get from the upload process). From there you can "draw" other things onto the image. You could start with your background image and draw the uploaded image onto the canvas. Keep in mind however that an uploaded image that is solid will just sit on top of (and hide) the background. I don't know what advanced capabilities the drawing classes have, such as adjusting opacity or those types of operations. I've used them for creating thumbnails and simple resizing, but nothing more at this point.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 8th, 2003, 12:23 PM
Authorized User
 
Join Date: Jun 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Help

I worked on it last night and came up with this. I am creating a new image 400x400 and then I want to place this existing image which is 200X200 on top of the 400x400 image. It work but the image the 200X200 images does not keep it's same scale. I need the 200X200 image to keep its same scale when I place it on top of the 400X400 image.

Thanks

 Dim bmp As New System.Drawing.Bitmap(imgSource, 200, 200)
'Create a new Bitmap and Graphics object to write too.
        Dim OutPutBitMap As Bitmap = New Bitmap(400, 400)
        Dim OutPutGraphics As Graphics = Graphics.FromImage(OutPutBitMap)
        OutPutGraphics.Clear(System.Drawing.ColorTranslato r.FromHtml("Black"))
        OutPutGraphics.DrawImageUnscaled(bmp, 0, 0)
        OutPutBitMap.SetResolution(96, 96)
        OutPutBitMap.Save("C:\aMerge\pp\NewImage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
        Me.Image1.ImageUrl = "C:\aMerge\pp\NewImage1.jpg"
 
Old December 8th, 2003, 10:17 PM
Authorized User
 
Join Date: Jun 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually the code worked the problem I was having is that I had to set the resolution of the first image to the same resolution of the final image. Here is the cleaned up code. This code takes an image and places it on a black background. This will give you a final image 400X400. You have to put in the adjustment if the first image is over 400X400.

        Dim imgSource As System.Drawing.Image = System.Drawing.Image.FromFile(PathFileName)

Dim bmp As New System.Drawing.Bitmap(imgSource, 200, 200)
bmp.SetResolution(72, 72)
'Create a new Bitmap and Graphics object to write too.
        Dim OutPutBitMap As Bitmap = New Bitmap(400, 400)
        Dim OutPutGraphics As Graphics = Graphics.FromImage(OutPutBitMap)
        OutPutGraphics.Clear(System.Drawing.ColorTranslato r.FromHtml("Black"))
        OutPutGraphics.DrawImageUnscaled(bmp, 0, 0)
        OutPutBitMap.SetResolution(72, 72)
        OutPutBitMap.Save(PathFileName, System.Drawing.Imaging.ImageFormat.Jpeg)
        Me.Image1.ImageUrl = PathFileName
 
Old December 9th, 2003, 09:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You can import the System.Drawing class and save some typing.

Imports System.Drawing

or

<%@ Import Namespace="System.Drawing" %>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
Combining PHP and C++ Waffles C++ Programming 0 August 3rd, 2007 01:20 PM
Combining two Queries arholly Access 1 January 16th, 2007 06:40 PM
Combining tables spraveens Access 2 December 29th, 2003 11:08 AM
Combining records OCM Access 2 November 19th, 2003 04:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.