LCD plugin supporting more than 70 display types (now with full graphics support!!!) (1 Viewer)

Status
Not open for further replies.

CHli

Portal Pro
July 5, 2005
1,251
14
Switzerland
Home Country
Switzerland Switzerland
Good news I could make your plugin work with a very easy fix :

I think there is a bug in one of the overloaded DrawImage(...) in System.Drawing.Graphics.

You are using this one :

graphics.DrawImage(image.Bitmap, image.X, image.Y);

which gave me a distorted image when saving the final buffer to the hdd (the same I could see on my LCD)

using this one fixes the problem :

graphics.DrawImage(image.Bitmap, image.X, image.Y, widthInPixels, heightInPixels);

Perhaps it's a problem of DPI between the graphics and the bitmap we want to draw but I hadn't time to check. (should not be a problem since you're creating the graphics from the bitmap anyway)

So just change this line (bonus : it fixes all the cases where the bitmap the user created doesn't fit the monitor size) :D

Enjoy and thanks JoeDalton !
 
D

dm15644

Guest
Somewhere in this 78 page thread I read about the issue that the iMON isnt't cleared when MP hibernates. Can't find it anymore....

It was said that MP doesn't shut down its plugins properly, and that's why the LCD isn't cleared.

Is there actually work being done to solve this problem? Any known workarounds that I missed?

Cheers

jayorck
 

JoeDalton

Retired Team Member
  • Premium Supporter
  • September 27, 2004
    425
    18
    56
    Belgium
    Home Country
    Belgium Belgium
    What version of MP are you using?
    I got confirmation of other iMon users that problem is fixed in the current (0.2.1) version.

    Joe
     
    D

    dm15644

    Guest
    Hi Joe and CHli

    I'm using 0.2.1, no SVN yet. I had the same with 0.2.0 and various SVNs. Before I didn't have an external display, so I cannot say.

    Sorry for being unprecise in my first post. The case is a bit tricky, I think it was the same in the older post. I'll repeat it anyway:

    - When entering standby or go to hibernation from the topbar menu, the display is cleared.
    - However, if the Power Scheduler sends the system to either standby or hibernation, the display is not cleared.

    As I mentioned I seem to remember that the cause was something like the MP not shutting down the plugins correctly when suspending or hibernating (or should I say Power Scheduler).

    I attach a log file where I sent the system to standby and then hibernation from topbar, and then to suspend from Power Scheduler.

    In External Display I'm using the "SoundGraph iMON USB Driver V1.0" on USB.

    Please let me know if you require more information.

    Thanks for your help!

    /jayrock
     

    CHli

    Portal Pro
    July 5, 2005
    1,251
    14
    Switzerland
    Home Country
    Switzerland Switzerland
    Just for the one who are following this thread.

    We had little chat with JoeDalton the other day and my fix is not possible as-is because he want to add the possibility to draw small image too (and stretch is not an option in this case)

    So if someone has the same problem it should take care of using normal windows DPI (using default windows font size) else it will have the same problem as I have.
     

    JoeDalton

    Retired Team Member
  • Premium Supporter
  • September 27, 2004
    425
    18
    56
    Belgium
    Home Country
    Belgium Belgium
    I already comitted a fix for this problem a couple of days ago, so it should be working OK in the current SVN version.

    I was going to let you know sooner but my PC decided to crash again (third time this year:mad:), so I had to wait until I got to work...

    FYI: the correct version of the method CHli pointed out is
    Code:
    graphics.DrawImage(image.Bitmap, new RectangleF(new PointF(image.X, image.Y), image.Bitmap.PhysicalDimension));

    This uses the real dimensions that are stored in the image. The previous version of the method calculated the image size according to the windows DPI setting. So if your DPI was set to 125%, the image was also enlarged to 125% of its physical size, leading to the results that CHli described.

    Joe
     

    CHli

    Portal Pro
    July 5, 2005
    1,251
    14
    Switzerland
    Home Country
    Switzerland Switzerland
    Hi JoeDalton,

    I had another problem (performance issues), when using your plugin I had some dropped frame and not a very smooth image in MyTV. I had a look at the code and I saw that in the LCD Hype wrapper the method : Bitmap.GetPixel(x,y) is used, and this method is very slow.

    So I managed to have the same behavious using the LockBits of the Bitmap object.

    I past my code here :

    To change in LcdHypeWrapper.cs :

    Code:
        public void DrawImage(int x, int y, Bitmap bitmap)
        {
          if (!SupportsGraphics)
          {
            return;
          }
          if (bitmap == lastBitmap)
          {
            return;
          }
          //clear the array
          Array.Clear(bytes, 0, bytes.Length);
          //a rectangle of the size of the bitmap
          Rectangle l_Size = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
          //get the bitmap data
          BitmapData l_Data = bitmap.LockBits(l_Size, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
          //create a source buffer for the bitmap data (RGB 24 bits)
          byte[] l_DestBuffer = new byte[l_Data.Stride * l_Size.Height];
          //copy the data buffer to the destination buffer
          Marshal.Copy(l_Data.Scan0, l_DestBuffer, 0, l_DestBuffer.Length);
          bitmap.UnlockBits(l_Data);
          for (int j = 0; j < l_Size.Height; j++)
          {
            for (int i = 0; i < l_Size.Width; i++)
            {
              //test if current pixel must be enabled or not
              if (l_DestBuffer[i * 3 + j * l_Data.Stride] == 0)
              {
                bytes[i + j * l_Size.Width] = 1;
              }
            }
          }
          m_tDllReg.InvokeMember("LCD_SendToGfxMemory", BINDING_FLAGS, null, null,
          new object[] { bytes, x, y, l_Size.Width - 1, l_Size.Height - 1, false });
          lastBitmap = bitmap;
        }

    And I moved the "bytes" variable to the class definition so it isn't allocated each time.

    With this modification I have smooth TV even when using graphical text. So I let you test and tell me if it's ok with you ? :)
     

    CHli

    Portal Pro
    July 5, 2005
    1,251
    14
    Switzerland
    Home Country
    Switzerland Switzerland
    Just to put some more interests in your plugin Joe here are some screens of my LCD :)

    0001.png


    0002.png


    0003.png


    0004.png


    0005.png
     
    Status
    Not open for further replies.

    Users who are viewing this thread

    Top Bottom