C# - Graphics.CopyFromScreen Creating Blank Image

Sep 19, 2011

I am using VB.NET to try and capture a portion of the screen so I found this code in several places to capture the whole screen:

Dim screenSize = SystemInformation.PrimaryMonitorSize
Dim bitmap = New Bitmap(screenSize.Width, screenSize.Height)
Using g As Graphics = Graphics.FromImage(bitmap)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screenSize)
End Using
bitmap.Save("c:scratchscreenshot.png", System.Drawing.Imaging.ImageFormat.Png)

This works with no error throw and the file is created successfully but the resulting image is completely transparent (it is the correct size) - This question relates to the same error but the solution is to use Win32 GDI which I want to avoid if possible

View 1 Replies


ADVERTISEMENT

Use Graphics.CopyFromScreen To Enable Alpha Transparent Controls?

Jun 27, 2012

I am trying to use (and this may be my problem already) e.Graphics.CopyFromScreen() in the OnPaint() method of my control to prepare a background onto which I can draw the content of the control. The goal is a tool-tip with rounded corners and other specific features to replace the default Windows tool tip.

Ideally the tool tip could be antialiased and blended into the backdrop, however at a pinch I could tolerate an aliased boundary. This may also be necessary as the control will often be covering a control with an OpenGL overlay and the whole blending procedure may end up a nightmare.

I have created a custom user control, a persistent instance of which belonds to my applications's main form, overriding the OnPaint and OnPaintBackground methods. The application of transparency however is challenging. As I understand, the graphics object passed to the paint method starts with a copy of the current VisibleClipBounds, where generally the first move is to clear the control with a solid colour and start drawing the main features. My first thought was to bypass the fill and start drawing on the captured background. For the first redraw this works fine, but subsequent redraws keep the previous content instead of re-capturing the backdrop. I hoped that CopyFromScreen would specifically eliminate the currently drawing control from its capture so as to start from a clean base but this is not the case, it captures the rectangle of the new location including the image of the previous location if it is in the bounds.

View 1 Replies

Interface And Graphics :: Creating A Class Holding Some Graphics?

Jan 12, 2011

Ok, I want to create a class that will handle a special rectangle graphic.In my form, I want to have two of these special rectangles. So, basically, I need two instances of that class in my form, right?I manage to initialize two, alright. But, how exactly am I supposed tomanage drawing/graphics etc in a class, and the results to be displayed in my form?

View 13 Replies

Creating A Blank Entry In A Databound ComboBox?

Oct 3, 2011

I have a databound ComboBox on my form. Is there any way that I can make the first field blank.

View 1 Replies

Quick Way Of Creating A New Blank Bitmap Say 1680x1050?

Jun 23, 2009

if there is a quick way of creating a new blank bitmap say 1680x1050 - just wondering cause i want to make a live animation that is this big ... but when looping this it is fairly slow while doing this...I have tried:

New method:
Dim B as new bitmap(1680,1050)

Create once then clone:

Static NewB as new bitmap(1680,1050)
Dim B as bitmap = NewB.Clone[code]....

All of the above are about as slow as each other...

View 2 Replies

Interface And Graphics :: Keep Graphics Over Image

Oct 28, 2011

I load my picturebox with a jpeg. If I put my DrawObjects() sub into picturebox paint event.When ever a picturebox.refresh or picturebox.visible = true (vb.net seems to draw my DrawObjects() first, then load the jpeg Image over my drawing - erasing drawing) Is there a way to get the picturebox to redraw the jpg image first then draw on it, in picturebox paint event?

View 10 Replies

Image.Save And Graphics.DrawString And Image Resolution?

Nov 13, 2011

I'm a VB beginner.I've been playing with Graphics.DrawString by watermarking a picture with a text string. The picture below to the left comes from PictureBox with a text string drawn with Graphics.DrawString. The font style used is Arial 48 points, regular, I think. The picture in PictureBox shows just as I configure. Great... The resolution of the original Terri Hatcher picture is 300 dpi (300 x 300). Exporting this picture with Graphics.DrawString, I get the picture below to the right. The text string appears a lot bigger than previously shown in PictureBox. It turns out that the text size varies, depending on the resolution of the original picture. That's kind of odd. I develop several graphics applications in a different environment and have never seen this sort of graphics.drawstring thing. Anyway,
my sample application seems to draw a text string at an image resolution of

[Code]...

View 3 Replies

Create A Blank Image In A Picturebox?

Oct 18, 2010

I'm using this snippet to create a blank image in a picturebox, but is it possible to have the image coloured so that I can see it. (I'll need to colour it later anyway).

.Image = New Bitmap(newPictureBox.Width, newPictureBox.Height) 'blank image.

Also if it is possible, I intend to draw lines, rectangles on the image (hopefully) and save the lot, so would I lose the colour, or would it get saved, or does it depend on what it gets saved as?

View 15 Replies

Background Image Field In Every Control Is Blank?

Oct 27, 2009

Dont know what happened but on every form whichever control is related with an image in the resource is not displaying image. I mean the background image field in every control is blank...

View 1 Replies

Why Image Icon Appear Blank / White In Upload Folder

Dec 30, 2011

I use vb.net. I am trying to do a file upload, I want the image to save to image folder, however, the image don't know appear in the directory that I indicate. If I click on "show all file", the image appear, but the image icon is blank or white like the image below show. So I click on that image and click on "include it in the project", however, it shouldn't be the case that I everytime upload an image, I need to redo that again. So how should I allow don't appear the white icon and to always appear in the upload folder when I upload a image instead of manually click on the image to include in?

This is my code
Protected Sub uploadImage()
Dim filename As String = FileUploadImg.FileName
Dim fileType As String = filename.Substring(filename.Length - 4).ToLower()
If (fileType = ".gif") Or (fileType = ".jpg") Or (fileType = ".png") Then
[Code] .....

View 2 Replies

Why Is Image Icon White/blank When Fileupload Save

Jan 15, 2012

i trying to do a file upload, i want to image to save to image folder, however, the image don't know appear in the directory that i indicate if i click on "show all file", the image appear, but the image icon is blank or white like the image below show so i click on that image and click on "include it in the project" , however, it shouldnt be the case that i everytime upload an image, i need to redo that again so how should i allow don't appear the white icon and to always appear in the upload folder when i upload a image instead of manually click on the image to include in ?is it visual studio problem? does i need to click on something to make the white icon disappear?

this is my code

Protected Sub uploadImage()
Dim filename As String = FileUploadImg.FileName
Dim fileType As String = filename.Substring(filename.Length - 4).ToLower()

[code].....

View 4 Replies

Creating A 3d Gl Graphics Chat - & C# ?

Sep 19, 2011

I want to create a 3d graphics chat. (Think Imvu Not Single Life. I tried opensim, that's a virtual world, not what I'm looking for, plus would prefer to code my own, as I was needing to rewrite so much)This chat I would run between friends on my own server (no monies for server costs)

First I need to know if I am on the right track or not.

ie : need 3d graphics engine at base ? (Any opensource ones I could look at legally to learn from?) need instant group chat engine?(Any opensource ones I could look at legally to learn from?) need login forms, web browser/viewer to run graphical chat in? plus of course I would need a database of meshes and so on?

So first I need to know if I'm looking into the right areas, plus where to find up to date tutorials (ie links) the web is huge? (Oh and opinions from more experienced people.)

Furthermore can this all be coded in vb.net or do i need to code part in C# and add together, can that be done?

Plus I am using a trial version of ms visual studio 10, I am unable to purchase it when trial runs out and do not know what I can switch to then that is free an legal to use, to learn an create opensource projects.

View 7 Replies

Creating A Grid For 2d Graphics?

Sep 2, 2010

My Problem is when i click zoom the Retangles location get Thrown Off somtimes and messes with my Grid.

Draw Graphics To Screen
Public DRAW As BufferedGraphics
' Array Holds of Rectangles Used For tiles to hold Graphics
Public TileRtang(5 * 5) As Rectangle

[Code]...

View 2 Replies

Creating Table At Runtime In .net, Image Control Doesn't Have Image Url Property?

Mar 10, 2010

i am creating a table in vb.net code (htmltable) with htmltablerows and htmltablecell. I gave on image control but thatr control cant have the .imageurl property, which i need cause i have a handler image.ashx which brings image from the database.
heres' the code -

TD = New HtmlTableCell
Dim img As New HtmlImage()
img.ID = "image_" & rd("ID")

[code]....

on the last line, "img.ImageUrl" i get this error -'ImageUrl' is not a member of 'System.Web.UI.HtmlControls.HtmlImage'how do i fix this?

View 1 Replies

Creating A Class That Holds/draws Some Graphics?

Jan 13, 2011

Ok, I want to create a class that will handle a special rectangle graphic.In my form, I want to have two of these special rectangles.So, basically, I need two instances of that class in my form, right?I manage to initialize two, alright. But, how exactly am I supposed to manage drawing/graphics etc in a class, and the results to be displayed in my form?

View 2 Replies

Creating Chess Graphics In Visual Basic?

Jun 16, 2012

I am creating a multiplayer chess game in Visual Basic.Net and I need to create tiles for the game. Earlier, I used buttons for the tiles, but then I realized that not only did they look ugly, but the coding part also became a problem. Also, the images of the chess pieces didn't properly fit on the buttons and they became distorted. Also, shifting the image to a different button every time a move was played also became very inefficient. So, in view of these difficulties, I want to build a proper board, but I have no idea where to start from or what controls to use for the design.

View 3 Replies

Interface And Graphics :: Creating A Graph From An Array?

Nov 29, 2008

I have the following array, (y axis) and wish display a curve. I am trying to find a way to code this so that can run it under Windows (PC) and under Windows mobile. The x axis increments 5 pixels with every point in my array.

Dim MyData() As Long = New Long(39) {10.0, 10.0, 10.0, 10.0, 11.0, 13.0, 16.0, 21.0, 30.0, 42.0, 54.0, 66.0, 78.0, 88.0, 92.0, 94.0, 95.0, 94.0, 93.0, 88.0, 82.0, 75.0, 66.0, 67.0, 72.0, 72.0, 67.0, 60.0, 55.0, 48.0, 41.0, 35.0, 29.0, 23.0, 18.0, 14.0, 12.0, 10.0

[code]......

View 13 Replies

Interface And Graphics :: Creating An Application With Mlutiple Forms

Mar 18, 2009

I am creating an application with mlutiple forms. When you click on a button in the main menu, the main menu will close and the new window will be diplayed. When you hit back on the new window, the main menu will be displayed.I know how to show new forms by using Form1.Show(). When I try to return to the main menu by hitting a back button I created, the main menu does not show up, but the program continues running. In the first form, I have the code: [code] Also, am I creating the new forms the right way for an application the will have maybe 15 forms?

View 2 Replies

Interface And Graphics :: Creating Good Perlin Noise With .Net Code?

Mar 31, 2012

I've been trying to get some help for this in another thread,but it looks like it's a task that is going to need a wider audience to try and find someone who knows something about writing/creating procedural textures at the pixel level in VB.Net. The VB6 example I'm trying to convert to VB.Net is attached to this post.

[Code]...

View 6 Replies

Interface And Graphics :: Creating Outlook Style Navigation User Control?

Feb 3, 2010

I believe that this is in the correct forum due to it being about creating an interface item, but if I am wrong then let me know and I'll try and bring this thread to the attention of the mods to be moved to a more appropriate forum. I am currently trying to create a generic navigation control with a similar style to the outlook navigation bar. I have figured out how I would be able to dynamically create the bottom part where you select the menu option, but I'm struggling to figure out how I would be able to create the top part, which can contain any user control that the developer would want.

So basically what I'm trying to figure out is, is there a way to allow for a developer to add controls to a specific area of your user control?If there is a way of achieving that then if anyone knows how to do this;In ASP.Net you have the login controls and with one of them, you are able to have different views depending on whether the user who is viewing the web page is logged in or not. Is there a way of achieving this in VB.Net for a user control that could be set up so that I could have the developer able to switch the view in the designer to show them the view for when a specific navigation option has been selected.

The one thing that I have thought of that could possibly cause a problem is having the capability of knowing when one of the user controls has been clicked, while I haven't figured this out exactly, I believe I should be able to achieve this by having an event for the navigation user control that provides the developer a reference to the control.

While I would hope that I have explained what I'm thinking well, its before my first coffee of the morning so I might have missed out some detail which would help someone to help me if I have then please let me know and I'll provide any details required.Also if what I'm envisioning is Pie in the sky, then let me know and I'll just have to make a base which I would just have to make a more bespoke system.

View 1 Replies

Draw An Image With The Graphics?

Nov 1, 2009

I have a very annoying problem, I am trying to draw an image with the Graphics class but when I do DrawImage, it automatically scales it up! heres some example code

graphics.DrawImage(My.Resources.TestImage, 20, 20)
PictureBox1.Image = My.Resources.TestImage

The picture box image is the correct size whereas the graphics drawn verison is too big!

View 3 Replies

Get Image From Graphics Handle?

Feb 24, 2009

I made a program that uses the graphics object to draw on a picture box. I used the graphics.fromhwnd(picbox) to draw on the control. The problem is if I minimize the window the drawing disapears. Might there be a way I can the image from the picbox and save it to a bitmap variable ?

View 1 Replies

Interface And Graphics :: Possible To Do Image Map

Apr 4, 2011

Just want to know if it is possible to do an image mapping in VB2010?..

View 3 Replies

Create An Image From A Graphics Object?

Sep 30, 2009

Is there a way to create an image from a graphics object?

View 3 Replies

Create Graphics On An Image In A Picture Box?

May 25, 2009

I am creating an application where when I click on an image I need to mark the place using the x and y co-ordinates given by the click and then after marking I put a red dot/circle on that spot and then I need to save this image to a file including the dot/circle I marked. I have tried saving the image to the file but to no avail, I have been able to only save the PictureBox image and that doesn't include the graphics. It is only the base image. I have tried to save it as a bitmap but have not gotten anywhere with that either. It seems whenever I call the image.save it takes only the value of the underlying image and saves it.

Private Sub BtnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCreate.Click
pointmarked = False

[Code]......

View 1 Replies

Create Persistent Graphics On Top Of An Image?

Mar 1, 2011

I am building a program which offers solutions to the travelling salesman problem (finding shortest tour between a set of cities while visiting each only once).

My program loads a bitmap image of a map into a picture box. From there, graphics which point out the cities as well as tour paths are drawn onto the map. My problem is that when the option to plot ALL cities is enacted, the user may choose to pinpoint a specific city with a separate control. When the user erases that pinpoint via an invalidation routine, though, it erases all graphics beneath it, which is undesirable. How can I make my tour graphics and city plots semi-permanent by drawing them directly on the image? I tried drawing them on a separate bitmap, but it 'covered up' the map image.

View 1 Replies

Graphics Wrong Image Interpolation In .Net?

Oct 4, 2011

When working with small images, the graphics interpolation does bad work.the result image in the following code does ignore second half of image to draw.Draw something on the image by using loadimage from JPG or whatever you want.

Dim GrayImage as system.drawing.Bitmap(640,480)
Dim bmTmp As New System.Drawing.Bitmap(GrayImage.Width, 1)
Using gr As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmTmp)[code]....

The second half vertical is not drawn by using the DrawImage methode. I want to have the image as result as you see on first picture. Stretched image with source on whole content.

View 4 Replies

Interface And Graphics :: How To Rotate An Image

Aug 21, 2011

I can get the image to rotate the problem is that on every step throught the loop the image goes to it inverse or draw backwards.

Code:
Public Class Form1
Public K As New Grid_Tiles
Public D As Integer

[code]....

View 1 Replies

Interface And Graphics :: Rotate A Jpg Image?

May 28, 2009

I have an application that downloads a .jpg snapshot from an IP camera, writes it to the server hard drive, attaches it to an email and sends it out to my users. Pretty simple until one guy had to mount his camera upside down and that's how he received the image via email.

It gets a bit annoying after a while, so he asked me if I could rotate it 180 degrees before attaching it to the email. I have absolutely no idea - hence my post. The app is on a hosted ASP.Net v3.5 web server.

View 7 Replies

VS 2010 : Get Raw Data Of Graphics Image?

Feb 6, 2012

get the raw data of zoomed image in a picture box. But I am zooming the image using,e.Graphics.DrawImage(Picturebox.Image, New Rectangle(ZoomXCordinate, ZoomYCordinate, ZoomWidth, ZoomHeight)).Now I am not getting how to get the raw data of zoomed graphics image displayed on the Picturebox.I am actually trying to get the image data into a byte array.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved