Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
GeneralRe: Draw a rect of image inside a part of picturebox Pin
Alomgir Miah16-Jun-05 7:56
Alomgir Miah16-Jun-05 7:56 
GeneralRe: Draw a rect of image inside a part of picturebox Pin
Sasuko16-Jun-05 8:14
Sasuko16-Jun-05 8:14 
GeneralRe: Draw a rect of image inside a part of picturebox Pin
Sasuko16-Jun-05 9:18
Sasuko16-Jun-05 9:18 
GeneralAdvanced problem Pin
snouto16-Jun-05 7:18
snouto16-Jun-05 7:18 
GeneralRe: Advanced problem Pin
nemopeti16-Jun-05 7:55
nemopeti16-Jun-05 7:55 
GeneralRe: Advanced problem Pin
DavidNohejl16-Jun-05 8:38
DavidNohejl16-Jun-05 8:38 
GeneralGeneric GDI+ error Pin
Alomgir Miah16-Jun-05 7:01
Alomgir Miah16-Jun-05 7:01 
GeneralRe: Generic GDI+ error Pin
Michael Potter16-Jun-05 8:45
Michael Potter16-Jun-05 8:45 
Straight from MSDN Image.FromStream docs:

Remarks<br />
You must keep the stream open for the lifetime of the Image object.


I created a Bitmap helper class that copied the bytes to MemoryStream and managed the Bitmap from there. Here are some of the methods of the class:

public void Load(Stream sm)
{
    Clear();
    int len = (int) sm.Length;
    byte[] buf = new byte[len];
    sm.Read(buf,0,len);
    	
    _ms = new MemoryStream(buf);
    _bm = (Bitmap) Image.FromStream(_ms);
}

public void Load(string fileName)
{
    FileStream fs = new FileStream(fileName,FileMode.Open,FileAccess.Read);
    Load(fs);
    fs.Close();
}

public void Load(object dbField)
{
    Clear();
    if (dbField != DBNull.Value)
    {
        byte[] buf = (byte[])dbField;
        _ms = new MemoryStream(buf);
        _bm = (Bitmap) Image.FromStream(_ms);
    }
}

public void Clear()
{
    if (_bm != null)
    {
        _bm.Dispose();
        _bm = null;
    }
    if (_ms != null)
    {
        _ms.Close();
        _ms = null;
    }
}

public Bitmap Bitmap
{
    get {return _bm;}
}

GeneralRe: Generic GDI+ error Pin
Alomgir Miah16-Jun-05 9:49
Alomgir Miah16-Jun-05 9:49 
GeneralValidating user login Pin
Guinness4Strength16-Jun-05 6:16
Guinness4Strength16-Jun-05 6:16 
GeneralRe: Validating user login Pin
nemopeti16-Jun-05 6:43
nemopeti16-Jun-05 6:43 
GeneralRe: Validating user login Pin
Guinness4Strength16-Jun-05 6:45
Guinness4Strength16-Jun-05 6:45 
GeneralRe: Validating user login Pin
nemopeti16-Jun-05 7:16
nemopeti16-Jun-05 7:16 
GeneralRe: Validating user login Pin
Guinness4Strength16-Jun-05 7:32
Guinness4Strength16-Jun-05 7:32 
GeneralRuntime cast down inheritance tree Pin
Gizz16-Jun-05 4:51
Gizz16-Jun-05 4:51 
GeneralRe: Runtime cast down inheritance tree Pin
S. Senthil Kumar16-Jun-05 5:10
S. Senthil Kumar16-Jun-05 5:10 
GeneralRe: Runtime cast down inheritance tree Pin
Colin Angus Mackay16-Jun-05 5:29
Colin Angus Mackay16-Jun-05 5:29 
QuestionIs it possible to store unicode as Ansi and convert back again? Pin
Member 9616-Jun-05 4:39
Member 9616-Jun-05 4:39 
AnswerRe: Is it possible to store unicode as Ansi and convert back again? Pin
Dave Kreskowiak16-Jun-05 5:08
mveDave Kreskowiak16-Jun-05 5:08 
GeneralRe: Is it possible to store unicode as Ansi and convert back again? Pin
Member 9616-Jun-05 5:11
Member 9616-Jun-05 5:11 
Answer*SOLVED* Pin
Member 9616-Jun-05 6:40
Member 9616-Jun-05 6:40 
GeneralRe: *SOLVED* Pin
Dave Kreskowiak16-Jun-05 8:09
mveDave Kreskowiak16-Jun-05 8:09 
GeneralParsing IL Pin
gantww16-Jun-05 4:06
gantww16-Jun-05 4:06 
GeneralRe: Parsing IL Pin
iliyang16-Jun-05 4:11
iliyang16-Jun-05 4:11 
QuestionImporting Macros from C header files? Pin
iliyang16-Jun-05 4:03
iliyang16-Jun-05 4:03 

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.