473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can I draw a PNG file like this?

Dear all,

I'm new here and I'm sorry to trouble.
But I've got the following problem when trying to draw a PNG file on a panel.
My code is like this:

Image mapImage = Image.FromFile (imageFileNames[i]);
Graphics graphics = this.splitContainer1.Panel1.CreateGraphics();
graphics.Clear(this.splitContainer1.Panel1.BackCol or);
graphics.DrawImage(mapImage, 10, 10, 50, 50);
this.splitContainer1.Panel1.Invalidate();

I can see that my imageFileNames[i] is correct.
But the image fails to appear on the screen.
Would anyone please help me out?

Thanks in advance.
Mar 29 '07 #1
2 1590
You have to draw it in the OnPaint method or the Paint event handler for the
Control.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
Networking Components, Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Kun Niu" <Ku****@discussions.microsoft.comwrote in message
news:26**********************************@microsof t.com...
Dear all,

I'm new here and I'm sorry to trouble.
But I've got the following problem when trying to draw a PNG file on a
panel.
My code is like this:

Image mapImage = Image.FromFile (imageFileNames[i]);
Graphics graphics = this.splitContainer1.Panel1.CreateGraphics();
graphics.Clear(this.splitContainer1.Panel1.BackCol or);
graphics.DrawImage(mapImage, 10, 10, 50, 50);
this.splitContainer1.Panel1.Invalidate();

I can see that my imageFileNames[i] is correct.
But the image fails to appear on the screen.
Would anyone please help me out?

Thanks in advance.

Mar 29 '07 #2
Thank you for reminding of this event.:)

I've tried the method.
And if I delete the last code, I can also make it.:)
Like this

Image mapImage = Image.FromFile (imageFileNames[i]);
Graphics graphics = this.splitContainer1.Panel1.CreateGraphics();
graphics.Clear(this.splitContainer1.Panel1.BackCol or);
graphics.DrawImage(mapImage, 10, 10, 50, 50);
//this.splitContainer1.Panel1.Invalidate();

"Kevin Spencer" wrote:
You have to draw it in the OnPaint method or the Paint event handler for the
Control.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
Networking Components, Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Kun Niu" <Ku****@discussions.microsoft.comwrote in message
news:26**********************************@microsof t.com...
Dear all,

I'm new here and I'm sorry to trouble.
But I've got the following problem when trying to draw a PNG file on a
panel.
My code is like this:

Image mapImage = Image.FromFile (imageFileNames[i]);
Graphics graphics = this.splitContainer1.Panel1.CreateGraphics();
graphics.Clear(this.splitContainer1.Panel1.BackCol or);
graphics.DrawImage(mapImage, 10, 10, 50, 50);
this.splitContainer1.Panel1.Invalidate();

I can see that my imageFileNames[i] is correct.
But the image fails to appear on the screen.
Would anyone please help me out?

Thanks in advance.


Mar 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: George | last post by:
I cannot understand how to fix my code so that it will work. It needs to draw a series of lines in different colors and save it to a ppm file. Could someone tell me what I have done wrong. Thanks a...
6
by: redneon | last post by:
Is it possible to draw directly to the screen using the .net libraries? I thought that it might be possible with GDI+ but I can't find out how to do it anywhere. A part of me suspects I may have to...
6
by: felix | last post by:
Hi, I have an Image that is drawn with Graphics.DrawImage(..). What I want to do is drawing it with a given transparency, e.g. at an alpha of only 180 instead of 255. How am I doing that?!?!?...
7
by: Devron Blatchford | last post by:
Hi there, I have created an owner draw menu item using DrawItem and MeasureItem in VB.NET. This seems to work well. I was wondering how I can do mouse over effects in these menus. Basically the...
0
by: Jasleen | last post by:
I am using Flash ocx to play the .swf file in a windowless container. Now I use IViewObject::Draw to render the contents on the HDC provided by me. I create a compatible DC passing NULL parameter....
1
by: zxo102 | last post by:
Hi everyone, I have tried two days to figure out how to draw the image in wx.BufferedDC on the page created by AddPage of wx.Notebook but still got no clue. The attached example works fine. If...
1
by: IvoShalev | last post by:
Hi there, I just want to give some sudgestions on how to draw some plain things only using the header file <graphics.hand of course the standart files <stdio.h<conio.h<stdlib.h>. First of All...
1
PEB
by: PEB | last post by:
Hi all, I want to Transform slide1 of multiple CorelDrow files to respective tiff files using Visual Basic or VB scripts... Manually it can be done for each Corel Draw file... Automatically...
7
by: Tem | last post by:
I need to draw a black lined circle and save it as a gif file. Can this be done with wpf or do I need to use GDI+ The examples I found seem to only apply to UI elements not a file. Thank you ...
1
by: akiarea | last post by:
Hi Please tell me how to create a bitmap. Draw on it and how to save that bitmap to a bmp file. I done following : on a button click event. CDC* pDC = GetDC(); CDC memDC;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.