I want to use the System.Drawing.Image class. According to the help file,
this is an abstract base class. Because it is supposedly abstract, I created
another class that inherits from it. However, when I did this I got the
following error:
'System.Drawing.Image.Image()' is inaccessible due to its protection level
Looking at other online examples, I found that the proper way to use it is
like this:
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
If this is an abstract base class, why can't I inherit from it and why am I
able to instantiate it as in the immediately above statement? 5 3250
Jerry,
You can inherit from it. However, we can't see how you have tried to
implement it, so we can't say what the problem might be. Can you post the
code of your implementation?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jerry J" <Je****@discussions.microsoft.comwrote in message
news:13**********************************@microsof t.com...
>
I want to use the System.Drawing.Image class. According to the help file,
this is an abstract base class. Because it is supposedly abstract, I
created
another class that inherits from it. However, when I did this I got the
following error:
'System.Drawing.Image.Image()' is inaccessible due to its protection level
Looking at other online examples, I found that the proper way to use it is
like this:
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
If this is an abstract base class, why can't I inherit from it and why am
I
able to instantiate it as in the immediately above statement?
I define a class like this:
public class Image : System.Drawing.Image
{
public Image() {}
}
The error: 'System.Drawing.Image.Image()' is inaccessible due to its
protection level occurs if I do this:
Image myImage = new Image();
The other thing I don't understand is why I am able to do the following
without getting an error. Since it is abstract, shouldn't this not be allowed
because it instantiates an image object?
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
--
Jerry J
"Nicholas Paldino [.NET/C# MVP]" wrote:
Jerry,
You can inherit from it. However, we can't see how you have tried to
implement it, so we can't say what the problem might be. Can you post the
code of your implementation?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jerry J" <Je****@discussions.microsoft.comwrote in message
news:13**********************************@microsof t.com...
I want to use the System.Drawing.Image class. According to the help file,
this is an abstract base class. Because it is supposedly abstract, I
created
another class that inherits from it. However, when I did this I got the
following error:
'System.Drawing.Image.Image()' is inaccessible due to its protection level
Looking at other online examples, I found that the proper way to use it is
like this:
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
If this is an abstract base class, why can't I inherit from it and why am
I
able to instantiate it as in the immediately above statement?
Jerry J wrote:
I define a class like this:
public class Image : System.Drawing.Image
{
public Image() {}
}
The error: 'System.Drawing.Image.Image()' is inaccessible due to its
protection level occurs if I do this:
Image myImage = new Image();
The other thing I don't understand is why I am able to do the following
without getting an error. Since it is abstract, shouldn't this not be allowed
because it instantiates an image object?
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
--
Jerry J
"Nicholas Paldino [.NET/C# MVP]" wrote:
Jerry,
You can inherit from it. However, we can't see how you have tried to
implement it, so we can't say what the problem might be. Can you post the
code of your implementation?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jerry J" <Je****@discussions.microsoft.comwrote in message
news:13**********************************@microsof t.com...
>
I want to use the System.Drawing.Image class. According to the help file,
this is an abstract base class. Because it is supposedly abstract, I
created
another class that inherits from it. However, when I did this I got the
following error:
>
'System.Drawing.Image.Image()' is inaccessible due to its protection level
>
>
Looking at other online examples, I found that the proper way to use it is
like this:
>
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
>
If this is an abstract base class, why can't I inherit from it and why am
I
able to instantiate it as in the immediately above statement?
You haven't instantiated it. You've called a static method, FromFile,
that returns a subclass of System.Drawing.Image, which you've assigned
to a base class reference (which is perfectly legal O-O). Try this:
System.Drawing.Image jpg = System.Drawing.Image.FromFile(PathToFile);
MessageBox.Show(String.Format("jpg type is {0}", jpg.GetType());
I think you'll see that the type is something other than "Image".
Jerry,
You can't really derive from System.Drawing.Image. I was looking at the
class in reflector, and all the constructors are marked as internal (as is
the default one with no parameters), which means that you can't define an
implementation outside of System.Drawing.dll.
The reason why the call to FromFile works is that FromFile is returning
an instance of a derived class. You can access abstract types in your code.
The whole point of abstract classes is that they help provide some base
implementation details (otherwise, it would be the same as an interface if
it only defined methods which needed to be overridden) so that you have a
contract (the class definition of the abstract type) which you can access,
regardless of the derived type.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jerry J" <Je****@discussions.microsoft.comwrote in message
news:37**********************************@microsof t.com...
>I define a class like this:
public class Image : System.Drawing.Image
{
public Image() {}
}
The error: 'System.Drawing.Image.Image()' is inaccessible due to its
protection level occurs if I do this:
Image myImage = new Image();
The other thing I don't understand is why I am able to do the following
without getting an error. Since it is abstract, shouldn't this not be
allowed
because it instantiates an image object?
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
--
Jerry J
"Nicholas Paldino [.NET/C# MVP]" wrote:
>Jerry,
You can inherit from it. However, we can't see how you have tried to implement it, so we can't say what the problem might be. Can you post the code of your implementation?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Jerry J" <Je****@discussions.microsoft.comwrote in message news:13**********************************@microso ft.com...
>
I want to use the System.Drawing.Image class. According to the help
file,
this is an abstract base class. Because it is supposedly abstract, I
created
another class that inherits from it. However, when I did this I got the
following error:
'System.Drawing.Image.Image()' is inaccessible due to its protection
level
Looking at other online examples, I found that the proper way to use it
is
like this:
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
If this is an abstract base class, why can't I inherit from it and why
am
I
able to instantiate it as in the immediately above statement?
OK, I understand now. I do think the Microsoft Help is a bit unclear. Thank
you for the info Bruce and Nicholas.
--
Jerry J
"Jerry J" wrote:
I define a class like this:
public class Image : System.Drawing.Image
{
public Image() {}
}
The error: 'System.Drawing.Image.Image()' is inaccessible due to its
protection level occurs if I do this:
Image myImage = new Image();
The other thing I don't understand is why I am able to do the following
without getting an error. Since it is abstract, shouldn't this not be allowed
because it instantiates an image object?
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
--
Jerry J
"Nicholas Paldino [.NET/C# MVP]" wrote:
Jerry,
You can inherit from it. However, we can't see how you have tried to
implement it, so we can't say what the problem might be. Can you post the
code of your implementation?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jerry J" <Je****@discussions.microsoft.comwrote in message
news:13**********************************@microsof t.com...
>
I want to use the System.Drawing.Image class. According to the help file,
this is an abstract base class. Because it is supposedly abstract, I
created
another class that inherits from it. However, when I did this I got the
following error:
>
'System.Drawing.Image.Image()' is inaccessible due to its protection level
>
>
Looking at other online examples, I found that the proper way to use it is
like this:
>
System.Drawing.Image Jpg = System.Drawing.Image.FromFile(PathToFile);
>
If this is an abstract base class, why can't I inherit from it and why am
I
able to instantiate it as in the immediately above statement?
>
>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Toby Mathews |
last post by:
Hi,
In an ASP.Net application I want to convert open create a FileStream
object from a System.Drawing.Image - is this possible? I create an instance
of an Image object using the FromFile method,...
|
by: SamSpade |
last post by:
There seems to be two ways to put things on the clipboard ( I don't mean
different formats): SetClipboardData and OleSetClipboard
If I want to get data off the clipboard do I care how it was put...
|
by: John via .NET 247 |
last post by:
Hi,
I'm using the System.Drawing.Bitmap namespace to load an image,and the RotateNoneFlipY method to flip that image before saving.However I have noticed that the saved image appears cropped...
|
by: Darrel |
last post by:
I'm grabbing a file from a file upload form field. This is a
'system.web.httppostedfile'
I would like to modify the image (Cropping/scaling) using
system.drawing.image.
Is there anyway to go...
|
by: Leszek L. |
last post by:
Hello, I am new to this group; if my question is OT then please
excuse me and tell me where to go.
I am using MS Visual C++ with some of its graphics libraries.
Now the compiler tells me that...
|
by: forest demon |
last post by:
for example, let's say I do something like,
System.Diagnostics.Process.Start("notepad.exe","sample.txt");
if the user does a SaveAs (in notepad), how can i capture the path that
the user...
|
by: Dave Keen |
last post by:
Hi all.
Hope you can help me. This should be easy but I can't make this work.
In brief I am building a page of thumbnails using images held in a
SQLServer 2000 database. I do this by creating...
|
by: mfunkmann |
last post by:
Hi,
I recently got an error and I don't know how to fix it:
Error 1 'System.Data.DataColumn' does not contain a definition for
'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO
I...
|
by: ThatsIT.net.au |
last post by:
I have this code that writes a pie chart in a asp.net page, but I want to
use it in a server control.
When I try I get a error on the last line "Response.OutputStream"
Obviously there is no...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |