The following creates a copy of an image. It worked fine in Visual Studio
2005, but after installing Visual Studio 2008 then opening the solution as a
..net 2.0 project, I get an error on the 'bmpOut.Palette = imageFile.Palet te'
line (see below).
Anyone come across this or suggest a reason for the error?
private static System.Drawing. Image CreateImageFile (System.Drawing .Image
imageFile, int width, int height)
{
System.Drawing. Bitmap bmpOut;
ImageFormat Format = imageFile.RawFo rmat;
bmpOut = new Bitmap(width, height,
PixelFormat.For mat64bppPArgb);
bmpOut.SetResol ution(imageFile .HorizontalReso lution,
imageFile.Verti calResolution);
/ /***** bmpOut.Palette = imageFile.Palet te;***** CAUSES ERROR
'INVALID PARAMETER//
Graphics g = Graphics.FromIm age(bmpOut);
g.Interpolation Mode =
System.Drawing. Drawing2D.Inter polationMode.Hi ghQualityBicubi c;
g.SmoothingMode =
System.Drawing. Drawing2D.Smoot hingMode.AntiAl ias;
g.PixelOffsetMo de =
System.Drawing. Drawing2D.Pixel OffsetMode.High Quality;
g.CompositingQu ality =
System.Drawing. Drawing2D.Compo sitingQuality.H ighQuality;
g.FillRectangle (Brushes.White, 0, 0, width, height);
g.DrawImage(ima geFile, 0, 0, width, height);
imageFile.Dispo se();
g.Dispose();
return bmpOut;
} 1 1477
Weird. Thought someone might know the answer to this one. I can't work out
why this no longer works in VS2008
"jj" <ab*@xyz.comwro te in message
news:eb******** *****@TK2MSFTNG P05.phx.gbl...
The following creates a copy of an image. It worked fine in Visual Studio
2005, but after installing Visual Studio 2008 then opening the solution as
a .net 2.0 project, I get an error on the 'bmpOut.Palette =
imageFile.Palet te' line (see below).
Anyone come across this or suggest a reason for the error?
private static System.Drawing. Image CreateImageFile (System.Drawing .Image
imageFile, int width, int height)
{
System.Drawing. Bitmap bmpOut;
ImageFormat Format = imageFile.RawFo rmat;
bmpOut = new Bitmap(width, height,
PixelFormat.For mat64bppPArgb);
bmpOut.SetResol ution(imageFile .HorizontalReso lution,
imageFile.Verti calResolution);
/ /***** bmpOut.Palette = imageFile.Palet te;***** CAUSES ERROR
'INVALID PARAMETER//
Graphics g = Graphics.FromIm age(bmpOut);
g.Interpolation Mode =
System.Drawing. Drawing2D.Inter polationMode.Hi ghQualityBicubi c;
g.SmoothingMode =
System.Drawing. Drawing2D.Smoot hingMode.AntiAl ias;
g.PixelOffsetMo de =
System.Drawing. Drawing2D.Pixel OffsetMode.High Quality;
g.CompositingQu ality =
System.Drawing. Drawing2D.Compo sitingQuality.H ighQuality;
g.FillRectangle (Brushes.White, 0, 0, width, height);
g.DrawImage(ima geFile, 0, 0, width, height);
imageFile.Dispo se();
g.Dispose();
return bmpOut;
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Dean |
last post by:
I get the following message when i try to set a pixel in the
bitmap.......whats wrong and how can i fix it.......
"Additional information: SetPixel is not supported for images with
indexed pixel formats."
this is the code.........
bitmap.SetPixel(biheight,biwidth,Color.Black);
|
by: Ma Xiaoguang |
last post by:
Dear ladies and gentlemen:
How to access all the pixels of a bitmap with C#? I am working with
Delphi before. In Delphi, you can use TBitmap.Scanline property to access
all the pixels of a bitmap object. How to do this with C#? Any hints? Thank
you very much.
Best regards.
Xiaoguang
|
by: Dale |
last post by:
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how can I
set the transparency so that the background is transparent.
In my application, the Bitmap that I am working with has several transparent
GIFs drawn on it and the transparency of each of them works within the
bitmap, but the bitmap overall gets saved with a black background.
Any help is greatly appreciated.
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
I'm using a Bitmap that has a palette of 256 colors (256 bytes).
I'm taking the Bitmap data by:
System.Drawing.Imaging.BitmapData refData = myBitmap.LockBits(new
Rectangle(0, 0, bmp.Width, bmp.Height),
System.Drawing.Imaging.ImageLockMode.WriteOnly, bmp.PixelFormat);
byte* buff = refData.Scan0.ToPointer();
And on this buff I'm iterating to set its data.
|
by: active |
last post by:
Guess I'm looking for someone who likes to work difficult puzzles.
I can't seem to ever retrieve a palette handle from the clipboard.
Below is a simple test program that demonstrates the problem.
The program uses windows api to get a handle to a palette from the
clipboard.
The palette needs to be put there by another program - maybe Photoshop.
| |
by: active |
last post by:
I've been looking on the Internet for a way to convert a DIB to a Bitmap
without success.
Now I'm wondering if that is the approach I should be taking.
All I want to do is display the DIB or draw it into a Bitmap.
Is there a graphics method that can help?
|
by: \Frank\ |
last post by:
I trying to learn what a Bitmap is. Not a Managed Bitmap Object but one
that, for example, comes from the clipboard with CF_BITMAP.
I'm guessing that a CompatableBitmap is an array of indices that point to
the colors in a Palette of the display driver.
So if I get a bitmap via CF_BITMAP I need to also get a Palette off the
clipboard and realize it then display the bitmap.
I believe "Realize it" means to put it into the display driver.
|
by: Piotrekk |
last post by:
Hi
I have a problem. I open bitmap file, load it to memory decrease color
palette by proceeding Euclidean distance. As a result i have image
reduced to - for example 18 colors. Once i save it -
Bitmap.Save(filename) reopen and check color of every pixel it seems
that there are over 41000 of different pixel colors. I need to save it
in such a way that there will be exactly 18 colors in a file. It seems
i have problem with it...
Can...
|
by: Joe Duchtel |
last post by:
Hello -
I have the following code to get a bitmap from the clipboard and to
save it to a *.png file ...
Dim lData As IDataObject = Clipboard.GetDataObject()
If lData.GetDataPresent(DataFormats.Bitmap) Then
Dim lPictureBox As New PictureBox
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |