Click here to Skip to main content
16,005,236 members
Home / Discussions / C#
   

C#

 
GeneralRe: Strange Problem with loading pictures Pin
Heath Stewart5-Apr-04 6:55
protectorHeath Stewart5-Apr-04 6:55 
GeneralIf (something) or (somethingElse) problem Pin
IanBatty4-Apr-04 22:45
IanBatty4-Apr-04 22:45 
GeneralRe: If (something) or (somethingElse) problem Pin
Colin Angus Mackay4-Apr-04 23:08
Colin Angus Mackay4-Apr-04 23:08 
GeneralRe: If (something) or (somethingElse) problem Pin
IanBatty4-Apr-04 23:20
IanBatty4-Apr-04 23:20 
GeneralRe: If (something) or (somethingElse) problem Pin
Adrian Stanley5-Apr-04 1:16
Adrian Stanley5-Apr-04 1:16 
GeneralRe: If (something) or (somethingElse) problem Pin
Jeremy Kimball5-Apr-04 3:42
Jeremy Kimball5-Apr-04 3:42 
Generalgenerate rtf code of pictures/images Pin
Jay Shankar4-Apr-04 18:50
Jay Shankar4-Apr-04 18:50 
GeneralRe: generate rtf code of pictures/images Pin
Heath Stewart4-Apr-04 19:33
protectorHeath Stewart4-Apr-04 19:33 
In the RTF specification, pictures can be encoded using hexidecimal or binary encoding. If you use binary (hexidecimal is more common), do not use CR/LF pairs to break lines (as is usual with binary files).

Getting the hexidecimal value of bytes isn't hard. Just loop through the bytes and output base16 char sequences:
Image img = new Bitmap("myimage.bmp");
MemoryStream ms = new MemoryStream();
img.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
StringBuilder sb = new StringBuilder(ms.Length * 2);
byte[] buffer = new byte[4096];
int read = ms.Read(buffer, 0, buffer.Length);
while (read != 0)
{
  for (int i=0; i<read; i++) sb.AppendFormat("{0:x2}", buffer[i]);
  read = ms.Read(buffer, 0, buffer.Length);
}
string hex = sb.ToString();
It's not exactly the most efficient, but you should get the idea.

There are several sections require to embed a pictures in RTF. Read more about embedding pictures in the RTF specification at http://msdn.microsoft.com/library/en-us/dnrtfspec/html/rtfspec_16.asp?FRAME=true#rtfspec_24[^].

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: generate rtf code of pictures/images Pin
Jay Shankar4-Apr-04 20:47
Jay Shankar4-Apr-04 20:47 
GeneralRe: generate rtf code of pictures/images Pin
Heath Stewart5-Apr-04 4:13
protectorHeath Stewart5-Apr-04 4:13 
GeneralRe: generate rtf code of pictures/images Pin
je_gonzalez5-Apr-04 12:44
je_gonzalez5-Apr-04 12:44 
GeneralRe: generate rtf code of pictures/images Pin
Jay Shankar5-Apr-04 15:15
Jay Shankar5-Apr-04 15:15 
GeneralComponent Properties Pin
dbetting4-Apr-04 17:57
dbetting4-Apr-04 17:57 
GeneralRe: Component Properties Pin
Heath Stewart4-Apr-04 18:10
protectorHeath Stewart4-Apr-04 18:10 
GeneralRe: Component Properties Pin
dbetting5-Apr-04 10:06
dbetting5-Apr-04 10:06 
GeneralRe: Component Properties Pin
Heath Stewart5-Apr-04 10:34
protectorHeath Stewart5-Apr-04 10:34 
QuestionGenerating listbox based on dataset? Pin
MeterMan4-Apr-04 17:45
MeterMan4-Apr-04 17:45 
AnswerRe: Generating listbox based on dataset? Pin
Heath Stewart4-Apr-04 18:06
protectorHeath Stewart4-Apr-04 18:06 
GeneralRe: Generating listbox based on dataset? Pin
MeterMan4-Apr-04 19:09
MeterMan4-Apr-04 19:09 
GeneralRe: Generating listbox based on dataset? Pin
MeterMan5-Apr-04 10:41
MeterMan5-Apr-04 10:41 
GeneralRe: Generating listbox based on dataset? Pin
Heath Stewart5-Apr-04 10:46
protectorHeath Stewart5-Apr-04 10:46 
GeneralRe: Generating listbox based on dataset? Pin
MeterMan5-Apr-04 11:03
MeterMan5-Apr-04 11:03 
GeneralRe: Generating listbox based on dataset? Pin
MeterMan5-Apr-04 14:37
MeterMan5-Apr-04 14:37 
GeneralRe: Generating listbox based on dataset? Pin
Heath Stewart5-Apr-04 17:20
protectorHeath Stewart5-Apr-04 17:20 
GeneralRe: Generating listbox based on dataset? Pin
MeterMan5-Apr-04 18:27
MeterMan5-Apr-04 18:27 

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.