Drawing Onto Another Image
May 2, 2010My objective here is to paint an image onto a certain part of ANOTHER image. So I'm technically trying to copy one picturebox to another one.
View 1 RepliesMy objective here is to paint an image onto a certain part of ANOTHER image. So I'm technically trying to copy one picturebox to another one.
View 1 RepliesWith this line...
If PictureBox1.Image = My.Resources._2star Then
I get this error: Operator '=' is not defined for types 'System.Drawing.Image' and 'System.Drawing.Bitmap'.Is there another way to say = with images?
Is it possible to convert an object form System.Drawing.Graphics to System.Drawing.Image?
View 4 RepliesHere is my favicon code
Dim oURL As Uri = New Uri(e.Uri.AbsoluteUri)
Dim favicon As Image
If oURL.HostNameType = UriHostNameType.Dns Then
[code]....
The error is Value of type System.Drawing.Image cannot be converted to System.Drawing.Icon Is it even possible to make the favicon be the icon of the form?
im using an MDI parent form and MDI Child. how can i print the image that's inside a picture box that's inside the Child from a button that's on the Parent?when i try to use print preview or print dialog, i can't get it to recognize that the document is the picure inside the picture box. i've looked up this error message:Value of type 'System.Drawing.Image' cannot be converted to 'System.Drawing.Printing.PrintDocument'.[code]
View 6 RepliesI am currently using Visual Studio 2008 (VB.Net) and SQL Server 2008. I have images saved on the database as image. When I fetch it into my code it is a System.Byte[] and I am unable to cast it as a System.Drawing.Image to save to my DevExpress(v10.2).XtraEditors.ImageEdit.
View 1 RepliesI am making a web browser using geckofx. I have put the favicon in a picture box but I have changed my mind and now I want it as the form's icon. The code for the favicon is:[code...]
The favicon works fine in the picture box but i think it will look better as an icon. If i change the line Me.PictureBox1.Image = favicon to Form1.icon = favicon I get the error Value of type 'System.Drawing.Image' cannot be converted to 'System.Drawing.Icon'. How can I get this to work?
I have a System.Drawing.Graphics g, which draw something in a PictureBox. Now I want to export this pGraphics to a new System.DrawingImage pImage (or Bitmap). But how?
Dim pImage As Bitmap
Dim g As Graphics
g = Graphics.FromImage(b)
[Code].....
I have two graphics I'm trying to superimpose into one, then display in a DataGridViewImage cell...The Value property of a DataGridViewImage is an Image type.
Dim Image1 As System.Drawing.Image = imgl_Imagelist1.Images(0)
Dim Image2 As New Bitmap(imgl_ImageList2.Images(0))
Dim DualGraphic As Graphics = Graphics.FromImage(Image1)
[code].....
How can I draw an image in a program using visual basic, without actually drawing the image first on an graphics program or on paper?
View 2 RepliesI am trying to use Bitblt for drawing one image on another. but when i try to get HDC From first image it gives Negative pointer value, so BitBlt returns 0 value. is it possible to get device context from bitmap directly?
[Code]...
I have an app that displays images (using picturebox component). what I am trying to do now is to try to allow the user to resize the image how he wants it (scale). for this i think I need to create an instanece (bmp) clone of the selected image in the picturebox and draw it ontop of the original picture; then specifi new set of size points.I was trying to use the code below:
Graphics.FromImage(PictureBox1.Image).BeginContainer('i do not know what to do here')
I need to specifi the new size of the graphics container but I do not seem to have any clue on how to do it.
I encounter a problem when I try to save a graphic. Drawing and displaying the graphic is no problem, but when I try to save it on file it always results in an empty image.
My code so far is:
Initialization:
Public Class ImageDisplay
[code].....
I want to draw a line on a image, easy enough in principal the image is a map and the lines is between city pairs?
View 12 RepliesI currently have a application that takes a image of the selected area that is set by the user.
I now would like to draw a black box in the section of a image
Top left
7, 458
Bottom right
512, 472
I would like that area filled up with a black box.
Been experimenting using VB.Net to make a game, Got most of it figured out but now my method of shooting missiles causes a terrible lag, This is how i'm doing it now.
Declares Private missiles As New ArrayList()
Dim canFire As Boolean = True
Fire
[CODE]...
Move all the missiles X positions + 1
Try
For Each pic As PictureBox In missiles
pic.Location = New Point(pic.Location.X + 1, pic.Location.Y)
Next
Catch ex As Exception
End Try
I have a timer making canFire true every second. It is a GIF Image, I tested with a PNG image and the lag is barely noticeable. Is there a better way to draw them while still being able to use GIF images?
i am creating a winform program using vb where i am loading an image into a picture box. then in the mouse down event i am creating small circles which can act as points which will be displayed on the image. say creating five points around the eye of a bird. then i am having a button by clicking it , a polygon will be drawn on those selected circles x and y as edges. i am having no issues until this. when i am trying to add another polygon in the same picture by clicking around its leg or whatever and pushed the draw button there must be another polygon i.e. two separate polygons 1 on eye and 2 on leg. but there is only one polygon from eye to leg. so my questions are
1) how to close a polygon and draw another one in picture box
2) how to select a previously drawn polygon and delete it.
picturebox_mousedown
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
[code].....
I have 4 control 3 button and 1 picturebox
vb.net
Private sub Button1 Dim bm As Bitmap = New Bitmap("D:Trening4 - Copy.bmp"
[code].....
My goal is actually very simple: I simply want a (shared) function that accepts a List(Of String) which creates an image and writes those strings (line by line) onto the image. There's a bit more to it than that, but for the sake of example this is all you need to know.Usually when drawing on an image I would create a Bitmap object and get the graphics object from Graphics.FromImage:
Dim bmp As New Bitmap(100, 100)
Using g As Graphics = Graphics.FromImage(bmp)
g.FillRectangle(...)
[code]....
Seems easy enough, but the problem is that I don't know how many strings there will be in the list, nor how long they will be. The image should 'scale itself' according to the strings in the list. If the list contains 5 strings it should be 5 strings high (plus a little extra for borders). If the list contains only 1 string it should be only one string high. Same goes for the width, if the longest string is 150 pixels, the image needs to be at least 150 pixels (160, 170 or something).
This is all good, I can get the dimensions of the strings by using Graphics.MeasureString. The problem now is that I need the dimensions of the image to create the bitmap. I need the Graphics object to get the dimensions. But, I need the bitmap to get the Graphics object I'm stuck in a loop here, if I don't have the Graphics object (I can't create it from nothing..) then I cannot measure the strings, but if I cannot measure the strings then I cannot determine how large my image will be, so I cannot create a bitmap and associated Graphics object...
I am new to vb.net, from VB6. Trying to understand drawing a simple line graph into a picturebox, which was so simple in VB6 ! From code snippets, I can see the basic idea using an bitimage to draw the lines and then showing it in a picturebox. I don't understand how to (simulate) scaling of the bitmap's x/y scales like you could do with VB6's .Scale.
View 1 RepliesQuestion: I get an exception serializing this class to a nHibernate xml file ({"Could not determine type for: System.Drawing.Image, System.Drawing, for columns:NHibernate.Mapping.Column(Settings)"}).
using System;
using System.Collections.Generic;
using System.Text;
[code].....
I have 1 image in picturebox. Now I draw some rectangles. I'm trying clear the image (only rectangles and left the image) without success.
Private Sub btnImageSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImageSelection.Click
Dim intImages As Integer = 0
Dim intImagesLine As Integer = 0
Dim intImagesColune As Integer = 0
picImage.Image = PictureBox1.Image
[Code] .....
The cycles for is for show the rectangules and works fine. but
i.Clear(Color.Blue)
The image is clear but the rectangles are showed and then unshowed.
The aim of my program is to load a picture into an pic box, then to be able to place multiple shapes on the picture in the pic box by clicking on the location where i want the shape. The type of shape will depend on the radio button which has been selected. Basically all i want is choice of X or O. (its not tic tac toe either At the end of it all i want to be able to save the image WITH the shapes on it, doesnt matter what format its in (gif, jpg, bmp) as long as it has color and i can see the original image with the shapes included.
I have made several attempts at this, and this is what i have so far. (I am brand new to VB and programming so i need all the help i can get) I have hit a wall with how far previous examples can get me.
[Code]...
How do i get System.Drawing.Image in the settings type?
i have a project with different buttons when a user clicks a button the image of PictureBox1 will change.
i want to save this image that the user has chosen after he closes the application, so it will be displayed in PictureBox1 when loaded.
i am using Microsoft Visual Basic 2010 Express
I'm currently developing a chess program. In my program, the problem I'm currently having is the slow drawing of the initial board. Here's part of my _gameGraph.DrawImage(MyResources.Marble_White, New Rectangle(x, y, 70, 70)) The code here draws the black & white squares using a for/next loop. I later use another for/next loop on the array holding the piece values, which uses the same type of function to draw the pieces on top of the squares. Both the pieces and the squares are .PNG images.
[Code]...
I'm currently working with these codes. Am I able to save my image and drawing into mySQL table? what codes should I use in order to save them into my table and I may need to able to retrieve it in a later part.
my codes:
Code:
Public Class Page_2
'Declare Starting Points For Drawn Objects
Private sStartX As Short
Private sStartY As Short
[code]....
How should i clean up after drawing to an image on a timer? I am getting a memory leak BTW I don't really understand why this is necessary; i mean shouldn't .net automatically clean up when an object has no longer any references to it?anyway here is basically the outline my
vb
Private Sub MainTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MainTimer.Tick
...
Dim FaceBit As Bitmap
[code]....
Right now I'm drawing a small 16x16 image on the title bar of my window. It works nicely, except for an obnoxious flicker that I cant figure out how to get rid of. I'm simply drawing the image like this:
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SIZE Then
wnd_size = New Size(New Point(CInt(m.LParam)))[code]....
Its repainting the entire title bar each time something is changed on it(click, mouseover the corner buttons, etc), and its during the repaint I get the flicker.
I'm writing a game in VB 2005 Express and at the moment it involves using the drawimage method to first draw a background and then various sprites onto my form every time a timer ticks. It's all double buffered so there's no flicker or anything but it just goes very slowly, how to speed it up. I've come across the term blitting (bitblt), which seems like it would be useful, but haven't been able to work out exactly what it is, whether it can be used in this version of vb, how to use it etc.
Here's my code (or at least an approximation of the relevant bits seeing as the whole thing is rather long):
Public Class Form1
Dim BackgroundImg as Image 'plus all of my sprite images declared
Dim Mybuffer As BufferedGraphics
Dim MyContext As BufferedGraphicsContext
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code] .....
When I try and compile code in vb.net 2008 I get an error that says "value of type 'system.drawing.image' cannot be converted to integer. The error happens at piccolor.image
GetDIBits(Form1.PictureBox1.Handle,
picColor.Image , _
0, Form1.PictureBox1.Height, pixels(1, 1, 1), _
bitmap_info, DIB_RGB_COLORS)
Here's the code that explains what piccolor.image is, it's a picturebox on form1 that has an image
readpic(Form1.PictureBox1)
Public Function readpic(ByVal picColor As PictureBox)
GetDIBits(Form1.PictureBox1.Handle,
picColor.Image , _
0, Form1.PictureBox1.Height, pixels(1, 1, 1), _
[Code] .....
And Imports System.Runtime.InteropServices is on the top of the module, if u need more code then let me know. Also I wonder if there is a way to bitblt directly to a pixel array.