简体   繁体   中英

BitMapEncoder in MonoTouch

I'm currently in the process of converting some standard C# files so they work in a MonoTouch iPhone application, however I have hit a wall with this method:

private void WriteTestFile(CGBitmapContext bitmapImage,  string fileName)
{
    try
    {
        using (FileStream stream5 = new FileStream(fileName, FileMode.Create))
        {
            BitmapEncoder encoder5 = new BmpBitmapEncoder();
            encoder5.Frames.Add(BitmapFrame.Create(bitmapImage));
            encoder5.Save(stream5);
            stream5.Close();
        }
    }
    catch (UnauthorizedAccessException)
    {
        // Do nothing
    }
}

I can't seem to find any equivalent to the BitmapEncoder class and I have no idea how to approach converting this part of the code, can anyone suggest a route to take?

Note: The original code used a WritableBitMap in pace of the CGBitmapContext.

I know nothing about MonoTouch nor iPhone.

However it looks like the function is just trying to save the bitmap image as BMP file. There must be an function in CGBitmapContext to Save to a file or some other class than can save a bitmap.

EDIT After further search, it looks like you should convert CGBitmapContext to a UIImage and then save it; seet How do I save an UIImage as BMP?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM