int main() { // uint32_t colors[] = { BLACK, WHITE, RED, GREEN, BLUE }; uint32_t *data = NULL; data=(uint32_t*)malloc(BMP_WIDTH*BMP_HEIGHT*sizeof(uint32_t)); bmp_rect(0, 0, BMP_WIDTH, BMP_HEIGHT, BLACK ,data); bmp_rect(5, 5, BMP_WIDTH-10, BMP_HEIGHT-10, WHITE ,data); bmp_ellipse(512, 512, 300, 300, GREEN, data); bmp_triangle(215,512,812,512,700,278,BLUE,data); bmp_line(512,700,512,278,RED,data); // Schreibe BMP Datei FILE *file = fopen("raster.bmp", "w"); //w steht für schreiben //a steht für anhängen bitmap_file_header(file); bitmap_info_header(file); for (int y = 0; y < BMP_HEIGHT; y++) { for (int x = 0; x < BMP_WIDTH; x++) { write_N_byte(file, data[y * BMP_WIDTH + x], 4); } } fclose(file); free (data); return 0; }
void HistogramImg::OnLButtonUp(UINT flags, CPoint point) { drawing_ = false; selection_rect_.NormalizeRect(); CClientDC dc(this); dc.DrawFocusRect(selection_rect_); Invalidate(); if (bmp_ != 0 && image_rect_.Width() > 0 && image_rect_.Height() > 0) { CRect rect= selection_rect_; CRect bmp_rect(0, 0, bmp_->GetWidth() - 1, bmp_->GetHeight() - 1); rect.left = (rect.left - image_rect_.left) * bmp_rect.Width() / image_rect_.Width(); rect.right = (rect.right - image_rect_.left) * bmp_rect.Width() / image_rect_.Width(); rect.top = (rect.top - image_rect_.top) * bmp_rect.Height() / image_rect_.Height(); rect.bottom = (rect.bottom - image_rect_.top) * bmp_rect.Height() / image_rect_.Height(); oStringstream ost; if (rect == bmp_rect) ost << _T("the whole photograph"); else ost << _T("rectangle from (") << rect.left << _T(", ") << rect.top << _T(") to (") << rect.right << _T(", ") << rect.bottom << _T(")"); rect_label_wnd_->SetWindowText(ost.str().c_str()); // CWaitCursor wait; if (selection_rect_.Width() * selection_rect_.Height() > 1000) ::SetCursor(::LoadCursor(0, IDC_WAIT)); // rebuild histogram hist_view_->Build(*bmp_, rect); } SetCursor(); ReleaseCapture(); }