I want to use my own 2 frames Image to paint my midikeyboardcomponent, but have some problem.
My code is like this:
#include "includes.h"
#pragma once
class myKey : public MidiKeyboardComponent
{
public:
myKey(File const& image, File const& image1, MidiKeyboardState &state, const Orientation orientation)
: MidiKeyboardComponent(state, orientation)
{
filmStrip = ImageFileFormat::loadFrom(image); //white
filmStrip1 = ImageFileFormat::loadFrom(image1); //black
setKeyWidth(filmStrip->getWidth() / 2); //white width
}
~myKey()
{
if (filmStrip)
delete filmStrip;
if (filmStrip1)
delete filmStrip1;
}
void drawWhiteNote (int midiNoteNumber, Graphics &g,
int x, int y, int w, int h,
bool isDown, bool isOver,
const Colour &lineColour, const Colour &textColour)
{
if (isDown)
g.drawImage(filmStrip, x, y, w, h,
filmStrip->getWidth() / 2, 0, filmStrip->getWidth() / 2, filmStrip->getHeight());
else
g.drawImage(filmStrip, x, y, w, h, 0, 0, filmStrip->getWidth() / 2, filmStrip->getHeight());
}
void drawBlackNote (int /*midiNoteNumber*/,
Graphics& g, int x, int y, int w, int h,
bool isDown, bool isOver,
const Colour& noteFillColour)
{
if (isDown)
g.drawImage(filmStrip1, x, y, w, h,
filmStrip1->getWidth() / 2, 0, filmStrip1->getWidth() / 2, filmStrip1->getHeight());
else
g.drawImage(filmStrip1, x, y, w, h, 0, 0, filmStrip1->getWidth() / 2, filmStrip1->getHeight());
}
Image* filmStrip;
Image* filmStrip1;
};
It seems it can’t call the constructor of MidiKeyboardComponent class. What’s wrong with it?
Besides, to paint my keyboard, is this code capable? What else should be added?
Thanks in advance.