I have 2 images (older and modern maps) and I want to show them as one on the screen. (I next start rotating and dragging corners until they match). My images are 7000x10000 pixels aprox.!!
I have the modifiable image in a picturebox, opacity .5. I tried to place the fixed image (as it is) as the form background image. But I only see the picturebox with the image at 50%. Without an image but with backcolor I see the image 50% and background color 50%. So the background shows through the picturebox. Setting both backcolor and backimage shows the color and not the image.
I then tried to use 2 pictureboxes, equal in size and location, each with an 50% opacity image. I only see the one that has "bringtofront".
I see in Paint.Net image editor when using layers, that it shows 2 images together, without much calculation. So DotNet can do it, but I don't know how. Any help please?
This is my code
Dim imageData As New BldData Public Sub CreateImg(fnd As String, fnm As String) PiBxForgr.BringToFront() PiBxBackgr.SendToBack() Me.BackColor = Color.Red PiBxBackgr.SizeMode = PictureBoxSizeMode.Zoom Dim bckgrFileInfo = New FileInfo(fnm) ' on background If File.Exists(bckgrFileInfo.FullName) Then Dim bitMap = New Drawing.Bitmap(bckgrFileInfo.FullName) Dim shownRect = New Rectangle(0, 0, bitMap.Width, bitMap.Height) imageData.bitMapBackgr = bitMap.Clone(shownRect, bitMap.PixelFormat) End If Dim frgrFileInfo = New FileInfo(fnd) ' in foreground If File.Exists(frgrFileInfo.FullName) Then imageData.bitMap = New Drawing.Bitmap(frgrFileInfo.FullName) imageData.shownRect = New Rectangle(0, 0, imageData.bitMap.Width, imageData.bitMap.Height) rePaint() End If imageLoaded = True End Sub Private Sub rePaint() PiBxForgr.SizeMode = PictureBoxSizeMode.Zoom imageData.bitMapForgr = imageData.bitMap.Clone(imageData.shownRect, imageData.bitMap.PixelFormat) PiBxBackgr.Image = SetImageOpacity(imageData.bitMapBackgr, 0.5) PiBxForgr.Image = SetImageOpacity(imageData.bitMapForgr, 0.5) End Sub Private Function SetImageOpacity(image As Image, opacity As Double) As Image Dim bmp As New Bitmap(image.Width, image.Height) Using gfx As Graphics = Graphics.FromImage(bmp) Dim matrix As New ColorMatrix() matrix.Matrix33 = opacity ' from 0.0 to 1.0 Dim attributes As New ImageAttributes() attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap) gfx.DrawImage(image, New Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes) End Using Return bmp End FunctionClass BldData Friend bitMap As Bitmap ' bitmap of picture in file, original, rotated or distorted Friend bitMapForgr As Bitmap ' bitmap of picture on screen Friend bitMapBackgr As Bitmap ' bitmap of picture on back Friend shownMap As Rectangle ' part of bitmap shown Friend scale As Integer ' total size / shown size Friend shownmapOrgWidth As Integer ... Properties ....End Class