Dividing toolbar strip bitmap?

Macaco

Freshman
Joined
Jul 5, 2004
Messages
39
Hello, I have a bmp with all the icons I want in my scrollbar, I have seen in some examples that It's not necessary to use separate bmp's....
But the problem is that I don't know how to separate it, I load al the strip by default, how can I separate it and pput it in diferent items of the same imageList?????

This is the code:

ImageList *imageList1;
imageList1 = new ImageList () ;

imageList1->ImageSize = System::Drawing::Size(16,16); //20
imageList1->TransparentColor = Color::White;
imageList1->Images->Add(Image::FromFile("juwelen.bmp"));

//I NEED TO DIVIDE MY BMP FILE INTO SEVERAL IMAGES IN ORDER TO FILL imaList ITEMS 1 and 2 (since I hace 3 icons in my bitmap)

ToolBar *toolBar1;
toolBar1 = new ToolBar();

ToolBarButton __gc *toolBarButton1 = new ToolBarButton();
ToolBarButton __gc *toolBarButton2 = new ToolBarButton();
ToolBarButton __gc *toolBarButton3 = new ToolBarButton();

toolBarButton1->ImageIndex = 0;
toolBarButton2->ImageIndex = 1; //item 1 doesn't exist !!!!
toolBarButton3->ImageIndex = 2; //item 2 doesn't exist !!!!

toolBar1->Buttons->Add(toolBarButton1);
toolBar1->Buttons->Add(toolBarButton2);
toolBar1->Buttons->Add(toolBarButton3);
toolBarButton1->ImageIndex = 0;
toolBarButton2->ImageIndex = 1;
toolBarButton3->ImageIndex = 2;
 
If I understand you correctly, you want to create different bitmaps from a bitmap strip? Why not use the width or height of the bitmap strip, divided by the number of bitmaps it contains, Then draw a new bitmap from the sectioned bitmap strip?
something like:

Visual Basic:
Dim i As Integer
Dim bmpStrip As Bitmap = New Bitmap(Bitmap.FromFile("path"))
Dim bmpSmall As Bitmap
Dim g As Graphics

For i = 0 To bmpStrip.Width Step 15
     bmpSmall = New Bitmap(16, bmpStrip.Height)
     g = Graphics.FromImage(bmpSmall)
     g.DrawImage(bmpStrip, i, 0)
     ImageList1.Images.Add(bmpSmall)
Next
g.Dispose
I haven't tested this...but it should work
 
The above should read:
Visual Basic:
Dim i As Integer
Dim bmpStrip As Bitmap = New Bitmap(Bitmap.FromFile("path"))
Dim bmpSmall As Bitmap
Dim g As Graphics

For i = 1 To bmpStrip.Width Step 16
     bmpSmall = New Bitmap(16, bmpStrip.Height)
     g = Graphics.FromImage(bmpSmall)
     If i = 1 Then
         g.DrawImage(bmpStrip, 0, 0)
    Else : g.DrawImage(bmpStrip, i, 0)
    End If
     ImageList1.Images.Add(bmpSmall)
Next
g.Dispose
 
Back
Top