Click here to Skip to main content
15,918,125 members
Home / Discussions / C#
   

C#

 
Generaldocument variables Pin
merlinos24-May-05 6:15
merlinos24-May-05 6:15 
QuestionHow we can pass a string variable to matlab Pin
hediii24-May-05 5:43
hediii24-May-05 5:43 
AnswerRe: How we can pass a string variable to matlab Pin
eggie524-May-05 12:42
eggie524-May-05 12:42 
AnswerRe: How we can pass a string variable to matlab Pin
hediii25-May-05 21:59
hediii25-May-05 21:59 
GeneralOPSEC SDK Pin
NitinR24-May-05 4:54
NitinR24-May-05 4:54 
GeneralRe: OPSEC SDK Pin
Judah Gabriel Himango25-May-05 4:18
sponsorJudah Gabriel Himango25-May-05 4:18 
Generalchange number color to 128 on a tif image Pin
kyfranBibax24-May-05 4:01
kyfranBibax24-May-05 4:01 
GeneralRe: change number color to 128 on a tif image Pin
kyfranBibax25-May-05 2:00
kyfranBibax25-May-05 2:00 
Hi,

I found how convert my image in 128 colors (2^7)
This is my code :
ImageCodecInfo myImageCodecInfo;
Encoder myEncoder;
EncoderParameter myEncoderParameter;
EncoderParameters myEncoderParameters;

//chnage the filename to obtain a tif file
Console.WriteLine(rasterFileName);
int index = rasterFileName.IndexOf(".");
string rasterFileNameTif = rasterFileName.Substring(0,index);
rasterFileNameTif = rasterFileNameTif.Insert(index, ".tif");
Console.WriteLine(rasterFileNameTif);

try
{
// Get an ImageCodecInfo object that represents the TIFF codec.
myImageCodecInfo = GetEncoderInfo("image/tiff");
// Create an Encoder object based on the GUID
// for the ColorDepth parameter category.
myEncoder = Encoder.ColorDepth;
// Create an EncoderParameters object.
// An EncoderParameters object has an array of EncoderParameter
// objects. In this case, there is only one
// EncoderParameter object in the array.
myEncoderParameters = new EncoderParameters(1);
// Save the image with a color depth of 7 bits per pixel (128 colors).
myEncoderParameter = new EncoderParameter(myEncoder, 24L);
myEncoderParameters.Param[0] = myEncoderParameter;
Console.WriteLine(myEncoder);
picChart.Image.Save(rasterFileNameTif,myImageCodecInfo,myEncoderParameters);

It works with all formats inputBig Grin | :-D
But when I have a tif file input (I want also tif output but in 128 colors), I have an exceptionCry | :(( :
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at displayRaster.displayRaster.ChangeRasterFormat() in c:\documents and settings\franck\mes documents\visual studio projects\displayraster\displayraster.cs:line 178


Do u know why?
Thx for replies.Cool | :cool:

Have a nice dayCool | :cool:

bibax en fait un max!
GeneralWMI Win32_PrintJob and windows service Pin
Member 198883924-May-05 3:58
Member 198883924-May-05 3:58 
Generalcould u tell me about Integrated Security=SSPI Pin
Trivikram Dwivedi24-May-05 3:56
Trivikram Dwivedi24-May-05 3:56 
GeneralRe: could u tell me about Integrated Security=SSPI Pin
Judah Gabriel Himango24-May-05 4:33
sponsorJudah Gabriel Himango24-May-05 4:33 
GeneralRe: could u tell me about Integrated Security=SSPI Pin
Trivikram Dwivedi25-May-05 1:05
Trivikram Dwivedi25-May-05 1:05 
Generaluninstall code Pin
Mohammad Daba'an24-May-05 3:33
Mohammad Daba'an24-May-05 3:33 
GeneralPrint Direct without Spool Pin
XamIam24-May-05 3:21
XamIam24-May-05 3:21 
GeneralRe: Print Direct without Spool Pin
Serdar YILMAZ24-May-05 3:36
Serdar YILMAZ24-May-05 3:36 
GeneralRe: Print Direct without Spool Pin
XamIam24-May-05 6:36
XamIam24-May-05 6:36 
QuestionCan i open a form into tabcontrol Pin
Trivikram Dwivedi24-May-05 2:25
Trivikram Dwivedi24-May-05 2:25 
GeneralReading Roadmap from bitmapimage Pin
Nomidada24-May-05 1:39
Nomidada24-May-05 1:39 
GeneralRebooting the PC from code Pin
exhaulted24-May-05 0:01
exhaulted24-May-05 0:01 
GeneralRe: Rebooting the PC from code Pin
Colin Angus Mackay24-May-05 0:07
Colin Angus Mackay24-May-05 0:07 
GeneralRe: Rebooting the PC from code Pin
User 665824-May-05 0:11
User 665824-May-05 0:11 
GeneralRe: Rebooting the PC from code Pin
exhaulted24-May-05 0:42
exhaulted24-May-05 0:42 
GeneralRe: Rebooting the PC from code Pin
User 665824-May-05 1:01
User 665824-May-05 1:01 
GeneralRe: Rebooting the PC from code Pin
exhaulted24-May-05 1:13
exhaulted24-May-05 1:13 
GeneralRe: Rebooting the PC from code Pin
ksanju100024-May-05 7:18
ksanju100024-May-05 7:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.