void __fastcall TCustomDrawDemoEditorForm::mruBkImagePropertiesButtonClick(
      TObject *Sender)
{
  if (OpenDialog->Execute()){
    Graphics::TBitmap *ABitmap = new Graphics::TBitmap();
    ABitmap->LoadFromFile(OpenDialog->FileName);
    GetSelectedDrawItem()->Bitmap = ABitmap;
    ((TcxCustomEdit*)Sender)->EditValue = "User Defined";
    CustomDrawDemoMainForm->cxDBVerticalGrid->Invalidate();
  }
}
Example #2
0
Pixmap::Pixmap(const string &f){
        Graphics::TBitmap* AuxBMP = new Graphics::TBitmap();
        AuxBMP->LoadFromFile(f.c_str());
        cols=AuxBMP->Width;
        rows=AuxBMP->Height;
        matrix = new colorRGBA[cols*rows];
        int c = 0;
        for (int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++) {
                        c = i * cols + j;
                        matrix[c][0]=GetRValue(AuxBMP->Canvas->Pixels[j][rows-i-1]);
                        matrix[c][1]=GetGValue(AuxBMP->Canvas->Pixels[j][rows-i-1]);
                        matrix[c][2]=GetBValue(AuxBMP->Canvas->Pixels[j][rows-i-1]);
                }
}
Example #3
0
void __fastcall THSVFormOrg::btn_Hue_Img_loadClick(TObject * Sender)
{
    if (!OpenDialog1->Execute())
	return;
    String Fpath;
    //Hue_Img->Picture->LoadFromFile(Fpath);

    Fpath = OpenDialog1->FileName;
    Graphics::TBitmap * Bitmap;

    Graphics::TBitmap * RefGraph;
    RefGraph = new Graphics::TBitmap();
    RefGraph->Height = Hue_Img->Height;
    RefGraph->Width = Hue_Img->Width;
    RefGraph->LoadFromFile(Fpath);
    Hue_Img->Picture->Graphic = RefGraph;
//        Hue_Img->Canvas->Draw(0,0,RefGraph);
    delete RefGraph;

}
Example #4
0
// Class functions.
TPresError
TGUIView::SetStyle( const char  *inStyleName )
{
  // Load the colors and widths of view elements from a bitmap resource or file.
  // The rows of the bitmap represent the elements in the order given by
  // the TGUIElements enumeration in GUI.h. An element's width is taken
  // by counting the number of pixels in its row that have the same color
  // as the leftmost one.

  if( inStyleName == NULL || *inStyleName == '\0' )
    return presNoError;

  TPresError  result = presNoError;
  Graphics::TBitmap   *bitmap = new Graphics::TBitmap();

  std::string fileName( inStyleName );
  for( std::string::iterator i = fileName.begin(); i != fileName.end(); ++i )
    *i = toupper( *i );
  fileName += ".BMP";

  // Look for a bitmap resource for the style given.
  try
  {
    bitmap->LoadFromResourceName( ( int )HInstance, fileName.c_str() );
  }
  catch( const EResNotFound& )
  {
    result = presResNotFoundError;
  }

  // No resource found, look for a bitmap file in the application default path.
  if( result == presResNotFoundError )
  {
    result = presNoError;
    try
    {
      bitmap->LoadFromFile( fileName.c_str() );
    }
    catch( ... )
    {
      result = presFileOpeningError;
    }
  }

  // No file found, look in the resource directory.
  if( result == presFileOpeningError )
  {
    result = presNoError;

    Util::TPath curPath;
    fileName = curPath + fileName;

    try
    {
      bitmap->LoadFromFile( fileName.c_str() );
    }
    catch( ... )
    {
      result = presFileOpeningError;
      gPresErrors.AddError( result, fileName.c_str() );
    }
  }

  if( result == presNoError )
  {
    for( int i = 0; i < MIN( int( numGUIElements ), bitmap->Height ); ++i )
    {
      TColor  curColor = bitmap->Canvas->Pixels[ 0 ][ i ];
      ElementColors[ i ].cl = curColor;
      int j = 0;
      while( j < bitmap->Width && bitmap->Canvas->Pixels[ j ][ i ] == curColor )
        ++j;
      ElementWidths[ i ] = j;
    }
  }

  delete bitmap;
  return result;
}