473,614 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bitmap Palette Error after migrating to VS2008

jj
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;
}

Sep 12 '08 #1
1 1477
jj
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;
}
Sep 16 '08 #2

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

Similar topics

1
6031
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);
4
23858
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
5
23894
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.
2
2416
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.
8
2484
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.
12
3347
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?
6
2455
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.
2
3858
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...
20
6985
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
0
8124
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,...
0
8621
Oralloy
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...
0
8576
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 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...
0
8427
tracyyun
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...
0
5538
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();...
0
4049
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...
0
4119
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2565
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
0
1421
bsmnconsultancy
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...

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.