Answered by:
extract image

Question
-
Good...
Well, what I want is to get image using a function (API) shell32.dll and show in pictureBox1, with a corresponding film tape, more like that of window 7 browser.
I tell my problem
1. I found this function shell32
<DllImport ( "shell32.dll")>
Public Shared Function SHGetDesktopFolder (_
As ppshf ByRef IShellFolder) As Integer
End Function
Public Interface IExtractImage
<PreserveSig ()> Sub GetLocation (_
As IntPtr pszPathBuffer ByVal _
ByVal cch As Integer, _
PdwPriority ByRef As Integer, _
As prgSize ByRef SIZE, _
DwRecClrDepth ByVal As Integer, _
PdwFlags ByRef As Integer)
<PreserveSig ()> Sub Extract (ByRef phBmpThumbnail As IntPtr)
End Interface
2. Load a video file from a dialog box and got the route
3. Apply the function, which allowed me to "remove image" and show in PictureBox1, but without the filmstrip, more like that of window xp browser.
my os is windows 7 32 bit.
According to the shell windows 7 it is already improved.
You can perform this operation?
Thank youMonday, September 5, 2016 9:32 PM
Answers
-
I could spend an example please
I don't know what that means.
This may or may not be a simple task as you don't really provide much information to go on.
If all you want to do is display images such that they appear to be part of a film frame then use two PictureBox's. On the Form drag the 1st PictureBox. In that PictureBox's Image property set the image to be the Frame image by browsing for the Frame image. Then on the Form drag the corners of the PictureBox until the PictureBox just encompasses the frame image.
Drag a new PictureBox onto the Form and place it in the first PictureBox. Drag the new PictureBox's corners until they cover the Frame area that will be used for displaying an picture to look like the picture is in the frame. The second PictureBox should have its BackgroundImageLayout set to stretch and images displayed in it should be displayed as its background image. Button1 code is for this.
Otherwise if you want to create images that have the film frame with also an image within the film frame that becomes more complex. As you then have to know what area within the film frame will be used to draw another image into so a final image can be displayed. I did that by using a Film Frame image that has transparent pixels within the Frame area where an image would be displayed in the Frame image and downloaded that here www.montograph.com. Code in the Form Load event creates a Rectangle necessary for knowing where in the Frame image to draw another image before setting PictureBox3's image as the new image. Button2 code is used for this image. This code will resize the image to be drawn in the Frame image to necessary dimensions.
If you download the frame image and then attempt to alter it with Microsoft Paint the transparent pixels will be lost when you save the altered image and then if you try to use the altered image with code in Form Load it will not work.
Option Strict On Public Class Form1 Dim PtsList As New List(Of Point) Dim Rect As Rectangle Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2))) Dim Bmp As New Bitmap(Image.FromFile("C:\Users\John\Desktop\Film Frame1.Png")) For y = 0 To Bmp.Height - 1 For x = 0 To Bmp.Width - 1 If Bmp.GetPixel(x, y) = Color.FromArgb(0, 0, 0, 0) Then PtsList.Add(New Point(x, y)) Me.Text = "Yes" End If Next Next Rect = New Rectangle(PtsList(0).X, PtsList(0).Y, (PtsList(PtsList.Count - 1).X - PtsList(0).X) + 2, (PtsList(PtsList.Count - 1).Y - PtsList(0).Y) + 2) Bmp.Dispose() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click PictureBox2.BackgroundImageLayout = ImageLayout.Stretch PictureBox2.BackgroundImage = Image.FromFile("C:\Users\John\Desktop\Picture Files\Crossbones Png.Png") End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Using Bmp1 As New Bitmap(Image.FromFile("C:\Users\John\Desktop\Film Frame1.Png")) PictureBox3.Size = Bmp1.Size Using Bmp2 As New Bitmap(Image.FromFile("C:\Users\John\Desktop\Picture Files\Crossbones Png.Png")) Using g As Graphics = Graphics.FromImage(Bmp1) g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic g.DrawImage(Bmp2, Rect.X, Rect.Y, Rect.Width, Rect.Height) PictureBox3.Image = CType(Bmp1.Clone, Image) End Using End Using End Using End Sub End Class
La vida loca
- Edited by Mr. Monkeyboy Tuesday, September 6, 2016 9:53 PM
- Proposed as answer by Neda Zhang Friday, September 9, 2016 9:07 AM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
Tuesday, September 6, 2016 9:51 PM -
I could spend an example please
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'Get image for frame. This might be a file, or a resource. Dim frame As Bitmap = Image.FromFile("<file path>\Frame.png") 'Get image from film. For this example it is a file (771x522). Dim IMG As Bitmap = Image.FromFile("<file path>\nkp.png") 'Get Graphicsobject for frame Dim G As Graphics = Graphics.FromImage(frame) 'Draw image into frame. These dimensions depend on the frame details. 'This frame is 800x600. The image proportions were different so it has been scaled. G.DrawImage(IMG, New Rectangle(70, 25, 660, 550), New Rectangle(0, 0, 771, 522), System.Drawing.GraphicsUnit.Pixel) 'Show image in picturebox PictureBox1.Image = frame End Sub
- Proposed as answer by Neda Zhang Friday, September 9, 2016 9:07 AM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
Tuesday, September 6, 2016 10:14 PM -
It serves me
thank you very much- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
Friday, September 9, 2016 8:37 PM
All replies
-
Well, what I want is to get image using a function (API) shell32.dll and show in pictureBox1, with a corresponding film tape, more like that of window 7 browser.
Create your frame using your favourite image editing program, and either save it as a file to be loaded by your app, or use it as a resource within the app. When you want to use it to frame another image, create a new bitmap object from that frame image, get a graphics object from the bitmap
https://msdn.microsoft.com/en-us/library/5y289054(v=vs.110).aspx
(option 3) and draw your image into that graphics object using DrawImagehttps://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage(v=vs.110).aspx
probably with this override:
https://msdn.microsoft.com/en-us/library/dbsak4dc(v=vs.110).aspxso that the image is positioned correctly within the frame. Then display the bitmap in the picture box.
- Edited by Acamar Tuesday, September 6, 2016 1:18 AM fmt
Tuesday, September 6, 2016 1:18 AM -
I could spend an example pleaseTuesday, September 6, 2016 4:09 PM
-
I could spend an example please
I don't know what that means.
This may or may not be a simple task as you don't really provide much information to go on.
If all you want to do is display images such that they appear to be part of a film frame then use two PictureBox's. On the Form drag the 1st PictureBox. In that PictureBox's Image property set the image to be the Frame image by browsing for the Frame image. Then on the Form drag the corners of the PictureBox until the PictureBox just encompasses the frame image.
Drag a new PictureBox onto the Form and place it in the first PictureBox. Drag the new PictureBox's corners until they cover the Frame area that will be used for displaying an picture to look like the picture is in the frame. The second PictureBox should have its BackgroundImageLayout set to stretch and images displayed in it should be displayed as its background image. Button1 code is for this.
Otherwise if you want to create images that have the film frame with also an image within the film frame that becomes more complex. As you then have to know what area within the film frame will be used to draw another image into so a final image can be displayed. I did that by using a Film Frame image that has transparent pixels within the Frame area where an image would be displayed in the Frame image and downloaded that here www.montograph.com. Code in the Form Load event creates a Rectangle necessary for knowing where in the Frame image to draw another image before setting PictureBox3's image as the new image. Button2 code is used for this image. This code will resize the image to be drawn in the Frame image to necessary dimensions.
If you download the frame image and then attempt to alter it with Microsoft Paint the transparent pixels will be lost when you save the altered image and then if you try to use the altered image with code in Form Load it will not work.
Option Strict On Public Class Form1 Dim PtsList As New List(Of Point) Dim Rect As Rectangle Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2))) Dim Bmp As New Bitmap(Image.FromFile("C:\Users\John\Desktop\Film Frame1.Png")) For y = 0 To Bmp.Height - 1 For x = 0 To Bmp.Width - 1 If Bmp.GetPixel(x, y) = Color.FromArgb(0, 0, 0, 0) Then PtsList.Add(New Point(x, y)) Me.Text = "Yes" End If Next Next Rect = New Rectangle(PtsList(0).X, PtsList(0).Y, (PtsList(PtsList.Count - 1).X - PtsList(0).X) + 2, (PtsList(PtsList.Count - 1).Y - PtsList(0).Y) + 2) Bmp.Dispose() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click PictureBox2.BackgroundImageLayout = ImageLayout.Stretch PictureBox2.BackgroundImage = Image.FromFile("C:\Users\John\Desktop\Picture Files\Crossbones Png.Png") End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Using Bmp1 As New Bitmap(Image.FromFile("C:\Users\John\Desktop\Film Frame1.Png")) PictureBox3.Size = Bmp1.Size Using Bmp2 As New Bitmap(Image.FromFile("C:\Users\John\Desktop\Picture Files\Crossbones Png.Png")) Using g As Graphics = Graphics.FromImage(Bmp1) g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic g.DrawImage(Bmp2, Rect.X, Rect.Y, Rect.Width, Rect.Height) PictureBox3.Image = CType(Bmp1.Clone, Image) End Using End Using End Using End Sub End Class
La vida loca
- Edited by Mr. Monkeyboy Tuesday, September 6, 2016 9:53 PM
- Proposed as answer by Neda Zhang Friday, September 9, 2016 9:07 AM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
Tuesday, September 6, 2016 9:51 PM -
I could spend an example please
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'Get image for frame. This might be a file, or a resource. Dim frame As Bitmap = Image.FromFile("<file path>\Frame.png") 'Get image from film. For this example it is a file (771x522). Dim IMG As Bitmap = Image.FromFile("<file path>\nkp.png") 'Get Graphicsobject for frame Dim G As Graphics = Graphics.FromImage(frame) 'Draw image into frame. These dimensions depend on the frame details. 'This frame is 800x600. The image proportions were different so it has been scaled. G.DrawImage(IMG, New Rectangle(70, 25, 660, 550), New Rectangle(0, 0, 771, 522), System.Drawing.GraphicsUnit.Pixel) 'Show image in picturebox PictureBox1.Image = frame End Sub
- Proposed as answer by Neda Zhang Friday, September 9, 2016 9:07 AM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:38 PM
Tuesday, September 6, 2016 10:14 PM -
It serves me
thank you very much- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Unmarked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
- Marked as answer by JenCarlos Friday, September 9, 2016 8:37 PM
Friday, September 9, 2016 8:37 PM -
thank you very muchFriday, September 9, 2016 8:39 PM