Skip to content

Commit

Permalink
Fixed black bar on frames
Browse files Browse the repository at this point in the history
  • Loading branch information
TcT2k committed Mar 15, 2015
1 parent a833bb4 commit 36bfea8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
35 changes: 12 additions & 23 deletions TexturePackPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,22 @@ void TexturePackPanel::UpdateFrameImage()

const Frame& frame = tex.at(m_frameSpinCtrl->GetValue());


m_frameBitmap->SetBitmap(GetFrameBitmap(frame, m_zoomSpinCtrl->GetValue()));
m_framePanel->Refresh();
m_framePanel->Layout();
}

wxBitmap TexturePackPanel::GetFrameBitmap(const Frame frame, int zoom)
{
wxSize imgSize = frame.GetSize();
imgSize *= m_zoomSpinCtrl->GetValue();
imgSize *= zoom;

wxBitmap frameBmp(imgSize, m_bitmap.GetDepth());
wxMemoryDC dstDC;
dstDC.SelectObject(frameBmp);
dstDC.SetBrush(wxBrush(m_colourPicker->GetColour()));
dstDC.SetPen(wxPen(m_colourPicker->GetColour()));
dstDC.DrawRectangle(wxPoint(0, 0), imgSize);

wxSharedPtr<wxGraphicsContext> dstGC(wxGraphicsContext::Create(dstDC));
Expand All @@ -95,11 +104,7 @@ void TexturePackPanel::UpdateFrameImage()
dstGC->DrawBitmap(srcSubBmp, 0, 0, imgSize.GetWidth(), imgSize.GetHeight());
dstGC.reset();

dstDC.SelectObject(wxNullBitmap);

m_frameBitmap->SetBitmap(frameBmp);
m_framePanel->Refresh();
m_framePanel->Layout();
return frameBmp;
}

void TexturePackPanel::OnFrameSpinCtrlEnterPressed( wxCommandEvent& event )
Expand Down Expand Up @@ -134,23 +139,7 @@ void TexturePackPanel::OnExportGIFClicked(wxCommandEvent& event)
const Texture& tex = m_texturePack->at(m_textureListBox->GetSelection());
for (auto frame = tex.begin(); frame != tex.end(); ++frame)
{
wxSize imgSize = frame->GetSize();

wxBitmap frameBmp(imgSize, m_bitmap.GetDepth());
wxMemoryDC dstDC;
dstDC.SelectObject(frameBmp);
dstDC.SetBrush(wxBrush(m_colourPicker->GetColour()));
dstDC.DrawRectangle(wxPoint(0, 0), imgSize);

wxSharedPtr<wxGraphicsContext> dstGC(wxGraphicsContext::Create(dstDC));
dstGC->SetAntialiasMode(wxANTIALIAS_NONE);
wxGraphicsBitmap srcSubBmp = dstGC->CreateSubBitmap(m_drawBitmap, frame->GetOffset().x, frame->GetOffset().y, frame->GetSize().GetWidth(), frame->GetSize().GetHeight());
dstGC->DrawBitmap(srcSubBmp, 0, 0, imgSize.GetWidth(), imgSize.GetHeight());
dstGC.reset();

dstDC.SelectObject(wxNullBitmap);

wxImage frameImg(frameBmp.ConvertToImage());
wxImage frameImg(GetFrameBitmap(*frame).ConvertToImage());

wxQuantize::Quantize(frameImg, frameImg, 256);

Expand Down
2 changes: 2 additions & 0 deletions TexturePackPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class TexturePackPanel : public BaseTexturePackPanel
wxSharedPtr<TexturePack> m_texturePack;

void UpdateFrameImage();

wxBitmap GetFrameBitmap(const Frame frame, int zoom = 1);
};

#endif // __TexturePackPanel__

0 comments on commit 36bfea8

Please sign in to comment.