I Hate to admit it but sort of lost using: bitmap.RotateImage( );

Does anyone have a basic example of the PROPER way to use Microsoft.SPOT Bitmap class
RotateImage();

I cannot seem to find a example to take a existing/created bitmap and rotate it by some degree and then display it on the LCD.

Should be easy, but…

I usually end up with a black rectangle with (maybe) some part of the image.
I once even trashed the Spider firmware. No deploy errors but Spider did not work after deploy.

Show your code please?

@ Architect -

Sorry for the delay but unexpected things I had to do.

The project was run on a Spider using a T35 LCD.

This is a sample that shows my main issue. Forget the displayed bitmap clipping and position.

My main question would be about the black rectangle (Bitmap b = new Bitmap(200, 180):wink: behind the bitmap rotated. I have not been able to change the black to a background color.

I do not understand why it is black or how to change/hide the background color.

The reason for asking the proper way to display a rotated bitmap someplace on the LCD (without it having the black background).

This sample code will show the black rectangle

image2.gif is the same as the bitmap I used for rotation.



using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

using MSPM = Microsoft.SPOT.Presentation.Media;

using Gadgeteer.Modules.GHIElectronics;
using GHI.Premium.System;


namespace GadgeteerTest1
{
    public partial class Program
    {
        //private DrawingContext dc;

        Bitmap bmpCopy;
        Bitmap bmpMyBitmap;
                
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            display_T35.SimpleGraphics.BackgroundColor = Colors.White;
            display_T35.SimpleGraphics.Clear();

            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);

            //Non transparent bitmap with blue background and black lines/text for testing
            bmpMyBitmap = Resources.GetBitmap(Resources.BitmapResources.image2); //Size is 150X150
            
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started. Press button");
        }


        //Used in case I trash my spider on last deploy (So app does not hang the Spider)
        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            Debug.Print("Button was pressed");

            //Test for now .. Need to find value of bitmap diagonal
            bmpCopy = new Bitmap(bmpMyBitmap.Width, bmpMyBitmap.Height);

            //Copy the bitmap. Position test to view our blue background bitmap
            bmpCopy.DrawImage(0, 0, bmpMyBitmap, 0, 0, bmpMyBitmap.Width, bmpMyBitmap.Height);

            bmpCopy.MakeTransparent(Microsoft.SPOT.Presentation.Media.Color.White);

            //This bitmap appears on the screen as the black rectangle
            Bitmap b = new Bitmap(200, 180); //No particular reason choosing this size

            //Be VERY careful of bitmap size/placement - The following code trashes Spider.. See note below code
            //b.RotateImage(45, 80, 80, bmpCopy, 0, 0, bmpCopy.Width, bmpCopy.Height, Bitmap.OpacityTransparent);
            //display_T35.SimpleGraphics.DisplayImage(b, 60, 60);

            //This (sort of works) except for black background
            //Assume I need a clipping rectangle?

            b.RotateImage(45, 0, 0, bmpCopy, 0, 0, bmpCopy.Width, bmpCopy.Height, Bitmap.OpacityOpaque);

            display_T35.SimpleGraphics.DisplayImage(b, 20, 20);
        }
        //     
    }
 }

/*

Trashed - This has caused firmware trash in the past
LCD shows (similar)
 
ABORT Data
Build Date:
Aug 15 2013
11:41:08

cps= 0x8000007f
pc= 0x00025640
lr= 0x000e09ce
sp= 0x4000f60c
*/



Thank you…

When you create b it is a black rectangle. Then you rotate another image into that black rectangle. And then you display it. If you don’t want black. You can create a bitmap of the size of the screen do all graphics operation into it and then display the whole thing using the T32 driver or Bitmap’s Flush() method.

@ Architect -

When you create b it is a black rectangle

I guess that is why it is black!

I wanted to avoid creating one large rectangle the size of the screen if possible.

Thanks for the reply.