|
oh yeh...now i initialized it as
b = new Bitmap(2,2);
exception is solved but after i press button for grey scale..Nothing is happening.
Cursor is going to Invalidate. And no change in pic
Thanks
|
|
|
|
|
You have modified a bitmap in memory; how would that affect your display ?
To get a visual change you must:
- make sure the bitmap is shown somewhere in a Form or Control (e.g. it gets drawn
in a Panel);
- tell that Form/Control that it needs to redraw because its content has changed;
you do this by calling Control.Invalidate()
Now a 2*2 bitmap probably is hardly visible at all, so dont expect a
huge change in your display when you grayscale it !
|
|
|
|
|
Sorry but its not too clear to me....
How to show bitmap on form or control ???
How to tell the form that it needs to redraw...?
And then how can i get a good change in display if 2*2 wont make much differnce..?
Thanks
|
|
|
|
|
Software_Specialist wrote: How to show bitmap on form or control ???
by drawing it in the form/control's paint handler, using Graphics.DrawImage
Software_Specialist wrote: How to tell the form that it needs to redraw...?
see previous message
Software_Specialist wrote: And then how can i get a good change in display if 2*2 wont make much differnce..?
try a larger bitmap !
|
|
|
|
|
ok now i know what you mean...
you mean to write as shown below:::
<br />
protected override void OnPaint (PaintEventArgs e)<br />
{<br />
Graphics g = e.Graphics;<br />
<br />
g.DrawImage(m_Bitmap, new Rectangle(this.AutoScrollPosition.X, this.AutoScrollPosition.Y, (int)(m_Bitmap.Width*Zoom), (int)(m_Bitmap.Height * Zoom)));<br />
}<br />
And for this i have to remove the picture box from the form. But i am writing an application for image viewer. i.e. Slide show and for that i need few of the image processing stuff..So for that i guess i need to have picture box ..
Moreover its not working out for me. I have just tried to load the picture with a following code
<br />
private void File_Load(object sender, System.EventArgs e)<br />
{<br />
OpenFileDialog openFileDialog = new OpenFileDialog();<br />
<br />
openFileDialog.InitialDirectory = "c:\\" ;<br />
openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp|Jpeg files (*.jpg)|*.jpg|All valid files (*.bmp/*.jpg)|*.bmp/*.jpg";<br />
openFileDialog.FilterIndex = 2 ;<br />
openFileDialog.RestoreDirectory = true ;<br />
<br />
if(DialogResult.OK == openFileDialog.ShowDialog())<br />
{<br />
m_Bitmap = (Bitmap)Bitmap.FromFile(openFileDialog.FileName, false);<br />
this.AutoScroll = true;<br />
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));<br />
this.Invalidate();<br />
}<br />
}<br />
But it gives me a blinkin form..I mean photo is not stable. It comes and go off every msec...
Well i am referring http://www.codeproject.com/cs/media/csharpgraphicfilters11.asp
Any solution...???
Thanks
|
|
|
|
|
I never felt the need for a PictureBox, I prefer drawing on a Panel, so I know
exactly what is being drawn, how it gets scaled, etc.
I never used AutoScroll but I think your AutoScrollMinSize is wrong;
I suggest you try it once without that line...
|
|
|
|
|
well no its not working without that aswell...
I am referring to CG article and in his demo its workin fine.
And yeah i am not drawing it on panel...Its just a form and that override command.
And what about slide show ? Would i be able to get that functionality if i draw on form without using picturbox.. ?
Thanks
|
|
|
|
|
a picturebox is like a panel that knows how to load an image file,
and how to draw an image; you already did both.
To make a slide show you just need to load and display consecutive images,
triggered by something (maybe a button click, maybe a timer tick).
BTW: you must Dispose of your OpenFileDialog !
|
|
|
|
|
yo removed OpenFileDialog and now using direct instance of it..
But no work as yet..Ok ill try to figure it out ....
Actually i am new to IP. But thanks for pointing me out these basic things..and so to basically we dont need any panel or picturebox dropped over form..We can just draw it once...oks
ill try to figure out the prob nw...
cheers
|
|
|
|
|
What I meant is you must call openFileDialog.Dispose() when you no longer need
that instance of OpenFileDialog, otherwise you may get a memory leak.
|
|
|
|
|
yeh got the solution to it...well doublebuffer property was set to false...
So i setted it to true and is working now...
ta
|
|
|
|
|
|
Hi,
I have created my own control, which extends another one. I am trying to add an event handler to an event raised by the parent class. How would I do this from within the constructor of the inheriting class?
For example the MouseClick event in a custom button. I want my control to handle its own event.
Thanks.
|
|
|
|
|
override this event
|
|
|
|
|
Hi,
I have implemented a control dragging system.
Basicly i'm dragging panels inside a panel.
The thing is that i decided to put an image in the main panel background.
But that makes my other panels leave a trail when i drag them.
Does anyone has an explanation/solution for this?
Thx,
Nuno
|
|
|
|
|
...A persistent trail? Meaning, it ghosts the panel all over the place and they artifact the screen? Try putting your panels inside a BufferedGraphics object(you need to double buffer your screen display....a BufferedGraphics object will implement the backbuffer for you)
Welcome my son...Welcome..to the Machine
|
|
|
|
|
Hi,
Thx for your reply.
Can you point me an example?
Thx,
Nuno
|
|
|
|
|
...just check out the BufferedGraphics entry in the msdn. That should get you started...repost in this thread if you still need further help after that and I'll see what I can pull up for you.
Welcome my son...Welcome..to the Machine
|
|
|
|
|
Oh....btw, are you using .NET 1.1 or .NET 2.0? ...The BufferedGraphics object is only available in 2.0
Welcome my son...Welcome..to the Machine
|
|
|
|
|
Hi, do you have c# program that draw cube?
Noha.Y
|
|
|
|
|
no...It doesn't work that way: But you can
look into Microsoft's XNA framework, and you can look up Direct3D tutorials. Building a 3D cube will be one of the first things you will build
or
do it the old fashioned way...register a Win32 Window, register your callback and message loop, and hack away inside your render code to build a cube(in Direct3D, OpenGL...or whatever graphics library you like)
My suggestion would be to look into the XNA. You'll be able to execute your DirectX code inside the CLR, so all of your resources will be inherently Managed.
Welcome my son...Welcome..to the Machine
|
|
|
|
|
How can I enter to XNA is?
Noha.Y
|
|
|
|
|
|
Can you give me another website to find directX and OpenGL? because my computer is not able to enter to www.gamedev.net
Thanks;
Noha.Y
|
|
|
|
|
...are you at work or something? I can't think of any other sites for certain. ...I'm sure GamaSutra would have tuts. ...Other than that, some simple web research should find tons of simple examples.
Typically, tutorials follow this kind of structure:
1.They'll start you off building the window...
2.You'll draw a 2D triangle
3.You'll rotate that triangle
4.You'll build a 3D cube
5.You'll build Halo
6.Sell Halo for $30,000,000 , call John Carmack and go "HAHAHAHAHAHA"
7.Start your own Gaming company
8.Get hot chicks
Welcome my son...Welcome..to the Machine
|
|
|
|