void enigma_rotor_window::draw(Cairo::RefPtr<Cairo::Context> cr) { vector<double> dashes; // Pattern used to draw a dashed line (15 pixels of line followed by 15 "empty" pixels) dashes.push_back(15.0); dashes.push_back(15.0); if (has_ellipse) { cr->save(); // Draw background ellipse cr->set_source_rgb(bkg_r, bkg_g, bkg_b); draw_ellipse(cr, x, y, ellipse_width, ellipse_height); cr->fill(); // Draw black border of background ellipse cr->set_source_rgb(BLACK); cr->set_line_width(1.2); draw_ellipse(cr, x, y, ellipse_width, ellipse_height); cr->stroke(); cr->restore(); } cr->save(); // Draw a line of width rotor_rim_width in the dash background colour cr->set_line_width(rotor_rim_width); cr->set_source_rgb(dash_bkg_r, dash_bkg_g, dash_bkg_b); cr->move_to(x + window_size, y - (2 * window_size)); cr->line_to(x + window_size, y + (2 * window_size)); cr->stroke(); // Draw a dashed line in the dash colour inside the previously drawn line // This creates the impression of "notches" on the handle/rim cr->set_source_rgb(dash_r, dash_g, dash_b); cr->set_dash(dashes, ((wheel_pos - 'A') & 1) * 15); // modifying the offset creates illusion of movement cr->move_to(x + window_size, y - (2 * window_size)); cr->line_to(x + window_size, y + (2 * window_size)); cr->stroke(); // Draw border around handle/rim cr->set_line_width(2.0); cr->unset_dash(); cr->set_source_rgb(DARK_GREY); cr->rectangle(x + padded_size, y - (2 * window_size), rotor_rim_width, (4 * window_size)); cr->stroke(); cr->restore(); draw_wheel_pos(cr, wheel_pos); if (has_ellipse) { // Draw screws upper->draw(cr); lower->draw(cr); } }
static enum test_res test002_func(void) { int i; u32 a, b, x1, x2, y1, y2; fill_rect(0, 0, fb_var.xres, fb_var.yres, black_pixel); for (i = 0; i <= Y_BLOCKS; i++) draw_hline(0, i*(fb_var.yres-1)/Y_BLOCKS, fb_var.xres, white_pixel); for (i = 0; i <= X_BLOCKS; i++) draw_vline(i*(fb_var.xres-1)/X_BLOCKS, 0, fb_var.yres, white_pixel); draw_ellipse(fb_var.xres/2, fb_var.yres/2, 3*fb_var.xres/8, fb_var.yres/2-1, white_pixel); a = (fb_var.xres-1)/X_BLOCKS; b = (fb_var.yres-1)/Y_BLOCKS; x1 = (fb_var.xres-1)/X_BLOCKS; y1 = (fb_var.yres-1)/Y_BLOCKS; x2 = (X_BLOCKS-1)*(fb_var.xres-1)/X_BLOCKS; y2 = (Y_BLOCKS-1)*(fb_var.yres-1)/Y_BLOCKS; draw_ellipse(x1, y1, a, b, white_pixel); draw_ellipse(x2, y1, a, b, white_pixel); draw_ellipse(x1, y2, a, b, white_pixel); draw_ellipse(x2, y2, a, b, white_pixel); wait_for_key(10); return TEST_OK; }
/* --------------------------------------- 绘制椭圆 (宽高) --------------------------------------- */ static bool_t qst_crh_ellps_wh ( __CR_IN__ void_t* parm, __CR_IN__ uint_t argc, __CR_IN__ ansi_t** argv ) { sRECT rect; sIMAGE* draw; sint_t sx, sy; uint_t ww, hh; /* 参数解析 <X> <Y> <Width> <Height> */ if (argc < 5) return (FALSE); draw = ((sQstView2D*)parm)->paint; if (draw == NULL) return (FALSE); sx = (sint_t)str2intxA(argv[1]); sy = (sint_t)str2intxA(argv[2]); ww = (uint_t)str2intxA(argv[3]); hh = (uint_t)str2intxA(argv[4]); rect_set_wh(&rect, sx, sy, ww, hh); draw_ellipse(draw, &rect, s_color, s_pixdraw); return (TRUE); }
/* --------------------------------------- 绘制椭圆 (坐标) --------------------------------------- */ static bool_t qst_crh_ellps_xy ( __CR_IN__ void_t* parm, __CR_IN__ uint_t argc, __CR_IN__ ansi_t** argv ) { sRECT rect; sIMAGE* draw; sint_t sx, sy; sint_t dx, dy; /* 参数解析 <X1> <Y1> <X2> <Y2> */ if (argc < 5) return (FALSE); draw = ((sQstView2D*)parm)->paint; if (draw == NULL) return (FALSE); sx = (sint_t)str2intxA(argv[1]); sy = (sint_t)str2intxA(argv[2]); dx = (sint_t)str2intxA(argv[3]); dy = (sint_t)str2intxA(argv[4]); rect_set_xy(&rect, sx, sy, dx, dy); draw_ellipse(draw, &rect, s_color, s_pixdraw); return (TRUE); }
void SoftwareRendererImp::draw_element(SVGElement* element) { // Task 4 (part 1): // Modify this to implement the transformation stack switch (element->type) { case POINT: draw_point(static_cast<Point&>(*element)); break; case LINE: draw_line(static_cast<Line&>(*element)); break; case POLYLINE: draw_polyline(static_cast<Polyline&>(*element)); break; case RECT: draw_rect(static_cast<Rect&>(*element)); break; case POLYGON: draw_polygon(static_cast<Polygon&>(*element)); break; case ELLIPSE: draw_ellipse(static_cast<Ellipse&>(*element)); break; case IMAGE: draw_image(static_cast<Image&>(*element)); break; case GROUP: draw_group(static_cast<Group&>(*element)); break; default: break; } }
void MainWindow::draw_isolines(const int activeDistributionNumber, QGraphicsScene * scene) { QPen pen; pen.setColor(QColor(10, 155, 10, 255)); pen.setWidth(1); QPainterPath path1; QPainterPath path2; QPainterPath path3; draw_ellipse(activeDistributionNumber, path1, 0.3); draw_ellipse(activeDistributionNumber, path2, 0.6); draw_ellipse(activeDistributionNumber, path3, 0.9); scene->addPath(path1, pen); scene->addPath(path2, pen); scene->addPath(path3, pen); }
//ellipse(x,y,rx,ry) : write a ellipse int ellipse(int x,int y,int rx,int ry) { if (SDL_MUSTLOCK(SDLscreen[c_screen])) SDL_LockSurface(SDLscreen[c_screen]); draw_ellipse(SDLscreen[c_screen],x,y,rx,ry,(Uint32)SDL_MapRGB(SDLdisplay->format,SDLcol.r,SDLcol.g,SDLcol.b)); if (SDL_MUSTLOCK(SDLscreen[c_screen])) SDL_UnlockSurface(SDLscreen[c_screen]); if (autotimer()!=0)return -1; return 0; }
void display( void ) { glClear( GL_COLOR_BUFFER_BIT ); // clear the window draw_circle(0); // size = 50 draw_ellipse(50); // size = 38 draw_triangle(88); // size = 3 draw_square(91); // size = 6 draw_square(97); // size = 6 draw_square(103); // size = 6 draw_square(109); // size = 6 draw_square(115); // size = 6 draw_square(121); // size = 6 glFlush(); }
void cairo_container::draw_list_marker( litehtml::uint_ptr hdc, const litehtml::list_marker& marker ) { if(!marker.image.empty()) { std::wstring url; t_make_url(marker.image.c_str(), marker.baseurl, url); lock_images_cache(); images_map::iterator img_i = m_images.find(url.c_str()); if(img_i != m_images.end()) { if(img_i->second) { draw_txdib((cairo_t*)hdc, img_i->second.get(), marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height); } } unlock_images_cache(); } else { switch(marker.marker_type) { case litehtml::list_style_type_circle: { draw_ellipse((cairo_t*) hdc, marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height, marker.color, 0.5); } break; case litehtml::list_style_type_disc: { fill_ellipse((cairo_t*) hdc, marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height, marker.color); } break; case litehtml::list_style_type_square: if(hdc) { cairo_t* cr = (cairo_t*) hdc; cairo_save(cr); cairo_new_path(cr); cairo_rectangle(cr, marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height); set_color(cr, marker.color); cairo_fill(cr); cairo_restore(cr); } break; } } }
static void init_flipellipse(F_ellipse *old_e, int px, int py) { F_ellipse *new_e; new_e = copy_ellipse(old_e); flip_ellipse(new_e, px, py, flip_axis); if (copy) { add_ellipse(new_e); } else { toggle_ellipsemarker(old_e); draw_ellipse(old_e, ERASE); change_ellipse(old_e, new_e); } /* redisplay objects under this object before it was rotated */ redisplay_ellipse(old_e); /* and this object and any other objects on top */ redisplay_ellipse(new_e); }
int main() { agg::grid_value* buf = new agg::grid_value[width * height]; agg::grid_rendering_buffer rbuf2(buf, width, height, width); agg::grid_renderer<agg::span_grid> ren_grid(rbuf2); agg::grid_rasterizer ras_grid; std::clog << "size char: " << sizeof(unsigned char) << "\n"; std::clog << "size int: " << sizeof(unsigned int) << "\n"; //ras_grid.gamma(0.0); //ras_grid.filling_rule(agg::fill_even_odd); ren_grid.clear(' '); draw_line(ras_grid, 120,120,20,70,10); ras_grid.render(ren_grid, 'a'); ras_grid.move_to_d(50,50); ras_grid.line_to_d(50,100); ras_grid.line_to_d(100,100); ras_grid.line_to_d(100,50); ras_grid.render(ren_grid, 'b'); draw_ellipse(ras_grid, 120,120,20,70); ras_grid.render(ren_grid, 'c'); ras_grid.move_to_d(200,200); ras_grid.line_to_d(200,300); ras_grid.line_to_d(300,300); ras_grid.line_to_d(300,200); ras_grid.render(ren_grid, 'd'); buf2grid(4,rbuf2); delete buf; return 0; }
static void fill_ellipse(DiaRenderer *self, Point *center, real width, real height, Color *colour) { WmfRenderer *renderer = WMF_RENDERER (self); W32::HPEN hPen; W32::HGDIOBJ hBrush, hBrOld; W32::COLORREF rgb = W32COLOR(colour); DIAG_NOTE(renderer, "fill_ellipse %fx%f @ %f,%f\n", width, height, center->x, center->y); hBrush = W32::CreateSolidBrush(rgb); hBrOld = W32::SelectObject(renderer->hFileDC, hBrush); draw_ellipse(self, center, width, height, NULL); W32::SelectObject(renderer->hFileDC, W32::GetStockObject (HOLLOW_BRUSH) ); W32::DeleteObject(hBrush); }
int main() { // 8位3通道图像 image = cvCreateImage( cvSize( IMG_WIDTH, IMG_HEIGHT ), IPL_DEPTH_8U, 3 ); // 置零 cvZero(image); temp = cvCloneImage( image ); // 创建窗口并设置鼠标事件回调函数 cvNamedWindow("Drawing"); cvSetMouseCallback("Drawing", my_mouse_callback, (void*) image ); while(1) { cvCopyImage( image, temp ); switch(g_draw_mode) { // 画线模式 case MODE_LINE: if(drawing_line) draw_line( temp ); break; // 画圆模式 case MODE_CIRCLE: if(drawing_circle) draw_circle( temp ); break; // 画椭圆模式 case MODE_ELLIPSE: if(drawing_ellipse) draw_ellipse( temp ); break; // 画多边形模式 case MODE_POLYGON: if(drawing_polygon) draw_polygon( temp ); break; } cvShowImage("Drawing", temp); // Esc键退出 // 对于不同的按键,画不同的图形(线、圆、椭圆、多边形) int choose = cvWaitKey(15); switch(choose) { // l-108 L-76 case 76: case 108: printf("当前处于画线模式.\n"); g_draw_mode = MODE_LINE; break; // c-99 C-67 case 67: case 99: printf("当前处于画圆模式.\n"); g_draw_mode = MODE_CIRCLE; break; // e-101 E-69 case 69: case 101: printf("当前处于画椭圆模式.\n"); g_draw_mode = MODE_ELLIPSE; break; // p-112 P-80 case 80: case 112: printf("当前处于画多边形模式.\n"); g_draw_mode = MODE_POLYGON; break; // Esc 退出 case 27: goto end; } } end: // 释放资源 cvReleaseImage( &image ); cvReleaseImage( &temp ); cvDestroyAllWindows(); return 0; }
FBCALL void fb_GfxEllipse(void *target, float fx, float fy, float radius, unsigned int color, float aspect, float start, float end, int fill, int flags) { FB_GFXCTX *context; int x, y, x1, y1, top, bottom; unsigned int orig_color; float a, b, orig_x, orig_y, increment; FB_GRAPHICS_LOCK( ); if (!__fb_gfx || radius <= 0.0) { FB_GRAPHICS_UNLOCK( ); return; } context = fb_hGetContext(); orig_x = fx; orig_y = fy; fb_hPrepareTarget(context, target); orig_color = color; if (flags & DEFAULT_COLOR_1) color = context->fg_color; else color = fb_hFixColor(context->target_bpp, color); fb_hSetPixelTransfer(context, color); fb_hFixRelative(context, flags, &fx, &fy, NULL, NULL); fb_hTranslateCoord(context, fx, fy, &x, &y); if (context->flags & CTX_WINDOW_ACTIVE) { /* radius gets multiplied by the VIEW/WINDOW width ratio (aspect is unchanged) */ radius *= (context->view_w / context->win_w); } if (aspect == 0.0) aspect = __fb_gfx->aspect; if (aspect > 1.0) { a = (radius / aspect); b = radius; } else { a = radius; b = (radius * aspect); } if ((start != 0.0) || (end != 3.141593f * 2.0)) { if (start < 0) { start = -start; get_arc_point(start, a, b, &x1, &y1); x1 = orig_x + x1; y1 = orig_y - y1; fb_GfxLine(target, orig_x, orig_y, x1, y1, orig_color, LINE_TYPE_LINE, 0xFFFF, COORD_TYPE_AA | (flags & ~COORD_TYPE_MASK)); } if (end < 0) { end = -end; get_arc_point(end, a, b, &x1, &y1); x1 = orig_x + x1; y1 = orig_y - y1; fb_GfxLine(target, orig_x, orig_y, x1, y1, orig_color, LINE_TYPE_LINE, 0xFFFF, COORD_TYPE_AA | (flags & ~COORD_TYPE_MASK)); } while (end < start) end += 2 * PI; while (end - start > 2 * PI) start += 2 * PI; increment = 1 / (sqrt(a) * sqrt(b) * 1.5); DRIVER_LOCK(); top = bottom = y; for (; start < end + (increment / 2); start += increment) { get_arc_point(start, a, b, &x1, &y1); x1 = x + x1; y1 = y - y1; if ((x1 < context->view_x) || (x1 >= context->view_x + context->view_w) || (y1 < context->view_y) || (y1 >= context->view_y + context->view_h)) continue; context->put_pixel(context, x1, y1, color); if (y1 > bottom) bottom = y1; if (y1 < top) top = y1; } } else { DRIVER_LOCK(); draw_ellipse(context, x, y, a, b, color, fill, &top, &bottom); } top = MID(context->view_y, top, context->view_y + context->view_h - 1); bottom = MID(context->view_y, bottom, context->view_y + context->view_h - 1); if( top > bottom ) SWAP( top, bottom ); SET_DIRTY(context, top, bottom - top + 1); DRIVER_UNLOCK(); FB_GRAPHICS_UNLOCK( ); }
void draw_circle(uint16_t x, uint16_t y, uint16_t radius) { draw_ellipse(x, y, radius, radius); }
void SoftwareRendererImp::draw_element( SVGElement* element ) { // Task 4 (part 1): // Modify this to implement the transformation stack //std::cout << element->transform << endl; //transform svg elements switch(element->type) { case POINT: { transformation = transformation * (element->transform); draw_point(static_cast<Point&>(*element)); transformation = transformation * (element->transform.inv()); break; } case LINE: { transformation = transformation * (element->transform); draw_line(static_cast<Line&>(*element)); transformation = transformation * (element->transform.inv()); break; } case POLYLINE: { transformation = transformation * (element->transform); draw_polyline(static_cast<Polyline&>(*element)); transformation = transformation * (element->transform.inv()); break; } case RECT: { transformation = transformation * (element->transform); draw_rect(static_cast<Rect&>(*element)); transformation = transformation * (element->transform.inv()); break; } case POLYGON: { transformation = transformation * (element->transform); draw_polygon(static_cast<Polygon&>(*element)); transformation = transformation * (element->transform.inv()); break; } case ELLIPSE: { transformation = transformation * (element->transform); draw_ellipse(static_cast<Ellipse&>(*element)); transformation = transformation * (element->transform.inv()); break; } case IMAGE: { transformation = transformation * (element->transform); draw_image(static_cast<Image&>(*element)); transformation = transformation * (element->transform.inv()); break; } case GROUP: { transformation = transformation * (element->transform); draw_group(static_cast<Group&>(*element)); transformation = transformation * (element->transform.inv()); break; } default: break; } }
bool GUI::on_display_area_button_press_handler(GdkEventButton *event_button, Controller &controller) { if (button_zoom_pointer.get_active() ) { // This is in relationship with the button setting for mouse selection of zoom center. if ( controller.mouse_into_image && controller.mouse_curser_changed == 1 && event_button->button == 1 ) { // Settings the zoom center coordinates by mutiplying the coordinates from inside the image per factors: controller.mouse_zoom_center_x = static_cast<float>(controller.mouse_inside_image_x) * controller.factor_width ; controller.mouse_zoom_center_y = static_cast<float>(controller.mouse_inside_image_y) * controller.factor_height ; controller.process_after_applying() ; // We register current frame in vector<cv::Mat> for undo-redo. // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset cursor. main_window_gdk_window->set_cursor() ; // Reset control variables: controller.mouse_curser_changed = -1 ; controller.draw_offset = 0.0 ; if ( button_zoom_pointer.get_active() ) { // If button pressed, raise it. button_zoom_pointer.set_active(false) ; } } else if (event_button->button != 1) { // Reset cursor. main_window_gdk_window->set_cursor() ; controller.reset_zoom_center(controller.current_image_to_process) ; controller.mouse_curser_changed = -1 ; if ( button_zoom_pointer.get_active() ) { // If button pressed, raise it. button_zoom_pointer.set_active(false) ; } } } else if ( button_draw_rect.get_active() || button_draw_line.get_active() || button_draw_circle.get_active() || button_draw_ellipse.get_active() || button_draw_polygon.get_active() || button_draw_star.get_active() || button_draw_text.get_active() ) { if ( controller.mouse_into_image && controller.mouse_curser_changed == 1 && event_button->button == 1 ) { if ( (controller.drawning_status == -1) || (controller.drawning_status == 1) ) { // Getting the drawning coordinates onto the real (not resized) image by multiplying per factors: controller.mouse_draw_x1 = static_cast<float>(controller.mouse_inside_image_x) * controller.factor_width ; controller.mouse_draw_y1 = static_cast<float>(controller.mouse_inside_image_y) * controller.factor_height ; controller.drawning_status = 0 ; controller.saved_frame = controller.current_image_to_process.clone() ; if ( button_draw_line.get_active() ) { goto fake_mouse_1_button_press ; } if ( button_draw_text.get_active() ) { goto fake_mouse_1_button_press ; } return false ; } else if (controller.drawning_status == 0) { fake_mouse_1_button_press : // Getting the drawning coordinates onto the real (not resized) image by multiplying per factors: controller.mouse_draw_x2 = static_cast<float>(controller.mouse_inside_image_x) * controller.factor_width ; controller.mouse_draw_y2 = static_cast<float>(controller.mouse_inside_image_y) * controller.factor_height ; controller.drawning_status = 1 ; cv::Scalar color(draw_color.get_blue_u() >> 8, draw_color.get_green_u() >> 8, draw_color.get_red_u() >> 8, draw_color.get_alpha_u() >> 8) ; cv::Mat frame = controller.current_image_to_process.clone() ; if (button_draw_line.get_active() ) { if ( controller.polylines_points_nb == 0) { controller.polylines_start_rect = cv::Rect( cv::Point(controller.mouse_draw_x1-7, controller.mouse_draw_y1-7), cv::Size(15, 15) ) ; } controller.polylines.push_back( cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1)) ; controller.polylines_points_nb++ ; if ( controller.polylines_points_nb > 1) { if ( controller.polylines_start_rect.contains(cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1)) ) { draw_polylines(frame , controller.polylines, true, (draw_thickness < 0), color, (draw_thickness < 0) ? 0 : draw_thickness , draw_line_type) ; controller.polylines_points_nb = 0 ; controller.polylines.clear() ; controller.polylines.shrink_to_fit() ; } else { draw_polylines(frame , controller.polylines, false, false, color, (draw_thickness < 0) ? 0 : draw_thickness, draw_line_type) ; } } } else if (button_draw_rect.get_active()) { cv::Rect rect( cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), cv::Point(controller.mouse_draw_x2, controller.mouse_draw_y2) ) ; draw_rect(frame, rect, color, draw_thickness, draw_line_type) ; } else if (button_draw_circle.get_active() ) { const int radius = static_cast<int>(roundf( sqrtf(powf(static_cast<float>(controller.mouse_draw_x2)-static_cast<float>(controller.mouse_draw_x1), 2) + powf(static_cast<float>(controller.mouse_draw_y2)-static_cast<float>(controller.mouse_draw_y1), 2))) ) ; draw_circle(frame, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), radius, color, draw_thickness, draw_line_type) ; } else if (button_draw_ellipse.get_active() ) { const int distance_x = abs(controller.mouse_draw_x1-controller.mouse_draw_x2) ; const int distance_y = abs(controller.mouse_draw_y1-controller.mouse_draw_y2) ; const cv::RotatedRect rot_rect(cv::Point2f( static_cast<float>(controller.mouse_draw_x1), static_cast<float>(controller.mouse_draw_y1) ), cv::Size(abs( distance_x * 2 ), abs( distance_y * 2 ) ), 0.0 ) ; draw_ellipse(frame, rot_rect, color, draw_thickness, draw_line_type) ; } else if (button_draw_polygon.get_active() && controller.config_draw_success == Gtk::RESPONSE_OK ) { const double radius = round( sqrt (pow(static_cast<double>(controller.mouse_draw_x2)-static_cast<double>(controller.mouse_draw_x1), 2) + pow(static_cast<double>(controller.mouse_draw_y2)-static_cast<double>(controller.mouse_draw_y1), 2)) ) ; vector<cv::Point> polygon ; double offset_correct = 0.0 ; if ((controller.polygon_edges > 4) && (controller.polygon_edges % 2 == 1)) { offset_correct = 360.0 / controller.polygon_edges / 2.0 / 2.0 ; } bool fill = false ; if ( ! controller.polygon_strikethrough && draw_thickness < 0 ) { fill = true ; } generate_polygon(controller.polygon_edges, radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), polygon, controller.polygon_strikethrough, false, controller.polygon_offset + controller.draw_offset + offset_correct) ; draw_polylines(frame, polygon, true, fill, color, ((draw_thickness < 0) ? 0 : draw_thickness) , draw_line_type) ; } else if (button_draw_text.get_active() && controller.config_draw_success == Gtk::RESPONSE_OK ) { int italic_flags = (controller.put_text_is_italic) ? cv::FONT_ITALIC : 0 ; draw_text(frame, controller.put_text_string, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), controller.put_text_font_face | italic_flags, controller.put_text_font_scale, color, ((draw_thickness < 0) ? 0 : draw_thickness), draw_line_type) ; controller.drawning_status = 1 ; } else if (button_draw_star.get_active() && controller.config_draw_success == Gtk::RESPONSE_OK ) { const double radius = round( sqrt (pow(static_cast<double>(controller.mouse_draw_x2)-static_cast<double>(controller.mouse_draw_x1), 2) + pow(static_cast<double>(controller.mouse_draw_y2)-static_cast<double>(controller.mouse_draw_y1), 2)) ) ; vector<cv::Point> star ; bool join_stroke = true ; bool fill = false ; if ( controller.star_correcting && (! controller.star_strokes) && (controller.star_pikes == 5 || controller.star_pikes == 6) ) { if ( ! controller.star_flower && ! controller.star_strikethrough && draw_thickness < 0 ) { fill = true ; } switch (controller.star_pikes) { case 5 : generate_pentagram(radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, controller.star_strikethrough, controller.star_flower, (360.0 / 5.0 / 2.0 / 2.0) + controller.star_offset + controller.draw_offset ) ; break ; case 6 : generate_hexagram(radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, controller.star_strikethrough, controller.star_flower, controller.star_offset + controller.draw_offset ) ; break ; } } else if ( ! controller.star_strokes) { if ( ! controller.star_flower && ! controller.star_strikethrough && ! controller.star_strokes && draw_thickness < 0 ) { fill = true ; } generate_star(controller.star_pikes , radius , cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, controller.star_strikethrough, controller.star_flower, controller.star_offset + controller.draw_offset + ((controller.star_pikes == 5) ? (360.0 / 5.0 / 2.0 / 2.0) : 0) ) ; } else { generate_polygon(controller.star_pikes, radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, false, true, controller.star_offset + controller.draw_offset ) ; join_stroke = false ; } draw_polylines(frame, star, join_stroke, fill, color, ((draw_thickness < 0) ? 0 : draw_thickness), draw_line_type) ; } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). frame.release() ; controller.saved_frame.release() ; controller.mouse_curser_changed = -1 ; return false ; } } else if (event_button->button == 3) {
void drawellipse( int x, int y, int Xradius, int Yradius ) { draw_ellipse(x,y,Xradius,Yradius,MAKE_COLORREF(r,g,b)); }
int main() { // Allocate the framebuffer unsigned char* buf = new unsigned char[width * height * 3]; // Create the rendering buffer agg::rendering_buffer rbuf(buf, width, height, width * 3); // Create the renderer and the rasterizer agg::renderer<agg::span_rgb24> ren(rbuf); agg::rasterizer ras; // Setup the rasterizer ras.gamma(1.3); ras.filling_rule(agg::fill_even_odd); ren.clear(agg::rgba8(255, 255, 255)); int i; // Draw random polygons for(i = 0; i < 10; i++) { int n = rand() % 6 + 3; // Make the polygon. One can call move_to() more than once. // In this case the rasterizer behaves like Win32 API PolyPolygon(). ras.move_to_d(random(-30, rbuf.width() + 30), random(-30, rbuf.height() + 30)); int j; for(j = 1; j < n; j++) { ras.line_to_d(random(-30, rbuf.width() + 30), random(-30, rbuf.height() + 30)); } // Render ras.render(ren, agg::rgba8(rand() & 0xFF, rand() & 0xFF, rand() & 0xFF, rand() & 0xFF)); } // Draw random ellipses for(i = 0; i < 50; i++) { draw_ellipse(ras, random(-30, rbuf.width() + 30), random(-30, rbuf.height() + 30), random(3, 50), random(3, 50)); ras.render(ren, agg::rgba8(rand() & 0x7F, rand() & 0x7F, rand() & 0x7F, (rand() & 0x7F) + 100)); } // Draw random straight lines for(i = 0; i < 20; i++) { draw_line(ras, random(-30, rbuf.width() + 30), random(-30, rbuf.height() + 30), random(-30, rbuf.width() + 30), random(-30, rbuf.height() + 30), random(0.1, 10)); ras.render(ren, agg::rgba8(rand() & 0x7F, rand() & 0x7F, rand() & 0x7F)); } // Write a .ppm file FILE* fd = fopen("agg_test.ppm", "wb"); fprintf(fd, "P6\n%d %d\n255\n", rbuf.width(), rbuf.height()); fwrite(buf, 1, rbuf.width() * rbuf.height() * 3, fd); fclose(fd); delete [] buf; return 0; }
// 鼠标事件回调函数 void my_mouse_callback(int event, int x, int y, int flags, void* param ) { IplImage * image = (IplImage * )param; switch(event) { // 鼠标左键按下 case CV_EVENT_LBUTTONDOWN: // 不同模式的选择 switch(g_draw_mode) { // 画线模式 case MODE_LINE: drawing_line = true; g_Line_startpoint = cvPoint( x, y ); break; // 画圆模式 case MODE_CIRCLE: drawing_circle = true; g_Circle_center = cvPoint(x, y); break; // 画椭圆模式 case MODE_ELLIPSE: drawing_ellipse = true; g_ellipse_center = cvPoint(x, y); break; // 画多边形模式 case MODE_POLYGON: drawing_polygon = true; // 构造当前点 myPoints* pNew; pNew = (myPoints*)malloc(sizeof(myPoints)); pNew->point = cvPoint(x, y); pNew->next = NULL; // 链表为空 if( pHead == NULL ) { pHead = pNew; pTail = pNew; } // 链表不空 else { pTail->next = pNew; pTail = pNew; } iNumofPoints++; break; } // 鼠标移动 case CV_EVENT_MOUSEMOVE: switch(g_draw_mode) { // 画线模式 case MODE_LINE: if(drawing_line) { g_Line_endpoint = cvPoint(x, y); } break; // 画圆模式 case MODE_CIRCLE: if(drawing_circle) { g_Circle_radius = getDistanceof2Points( g_Circle_center, cvPoint( x, y ) ); } break; // 画椭圆模式 case MODE_ELLIPSE: if(drawing_ellipse) { g_ellipse_axes = cvSize( abs( x - g_ellipse_center.x ), abs( y - g_ellipse_center.y ) ); } break; } break; case CV_EVENT_LBUTTONUP: switch(g_draw_mode) { // 画线模式 case MODE_LINE: drawing_line = false; draw_line( image ); g_Line_endpoint = cvPoint(-1, -1); break; // 画圆模式 case MODE_CIRCLE: drawing_circle = false; draw_circle( image ); g_Circle_radius = -1; break; // 画椭圆模式 case MODE_ELLIPSE: drawing_ellipse = false; draw_ellipse( image ); g_ellipse_center = cvPoint(-1, -1); break; } break; // 右键按下,清除所有图像 case CV_EVENT_RBUTTONDOWN: { printf("清除所有图像.\n"); cvZero( image ); // 画多边形模式,额外的处理 if(g_draw_mode == MODE_POLYGON) { g_polygon_pts[0] = NULL; iNumofPoints = 0; pHead = pTail = NULL; g_polygon_npts = NULL; } } break; } }
void MainWindow::draw() { if (scene) { delete scene; scene = NULL; } int vec1 = ui.component1->value() - 1; int vec2 = ui.component2->value() - 1; calculate_bounding_rect(vec1, vec2); shiftX = 0.0; shiftY = 0.0; QPen pen; // scene = new QGraphicsScene(boundingRect, this); scene = new QGraphicsScene(this); //draw axies lines pen.setColor(QColor(0, 0, 0, 255)); pen.setWidth(1); scene->addLine(plot_x(0.0), plot_y(0.0), plot_x(1.0), plot_y(0.0), pen); scene->addLine(plot_x(0.0), plot_y(0.0), plot_x(0.0), plot_y(1.0), pen); //draw all points if (ui.checkBoxSelection->isChecked()) { pen.setColor(QColor(255, 0, 0, 255)); pen.setWidth(2); for (int i = 0; i < selectionSize; ++i) scene->addLine(plot_x(x[i][vec1]), plot_y(x[i][vec2]), plot_x(x[i][vec1]), plot_y(x[i][vec2]), pen); } //draw middle point if (ui.checkBoxMiddle->isChecked()) { pen.setColor(QColor(0, 0, 255, 255)); pen.setWidth(3); scene->addLine(plot_x(middleX), plot_y(middleY), plot_x(middleX), plot_y(middleY), pen); } //draw isolines if (ui.checkBoxIsolines->isChecked()) { pen.setColor(QColor(0, 0, 255, 255)); pen.setWidth(1); QPainterPath path1; QPainterPath path2; QPainterPath path3; draw_ellipse(path1, 0.3); draw_ellipse(path2, 0.6); draw_ellipse(path3, 0.9); scene->addPath(path1, pen); scene->addPath(path2, pen); scene->addPath(path3, pen); } scene->setBackgroundBrush(QBrush(QColor(0, 255, 0, 255))); ui.graphicsView->setScene(scene); ui.graphicsView->show(); }
// Parse the next command. BOOL WMFUpdateState::parse_next_command(BOOL *primitive) { BOOL fPrimitive = FALSE; // Remember the start of the record. ST_DEV_POSITION lRecordOffset; file.tell(&lRecordOffset); // Read the next record. METARECORD Record; if ((error = file.read(&Record, sizeof(Record)-sizeof(Record.rdParm))) != ERRORCODE_None) { return FALSE; } // TRACE("Record %d function: %04x, size: %08lx\n", m_nRecord, Record.rdFunction, Record.rdSize); // Process the record. switch (Record.rdFunction) { case 0: { // End of records. All done. return FALSE; } case META_ESCAPE: { // short n; // file.read(&n, sizeof(n)); // TRACE("Escape: %x\n", n); break; } case META_SETROP2: case META_SETRELABS: case META_SETMAPMODE: { // TRACE("IGNORED Record %d function: %04x, size: %08lx\n", m_nRecord, Record.rdFunction, Record.rdSize); break; } case META_SETTEXTALIGN: { short nAlign; file.read(&nAlign, sizeof(nAlign)); SetTextAlign(nAlign); break; } case META_SETBKCOLOR: { COLORREF Color; file.read(&Color, sizeof(Color)); SetBkColor(Color); break; } case META_SETBKMODE: { short nMode; file.read(&nMode, sizeof(nMode)); SetBkMode(nMode); break; } case META_SETTEXTCOLOR: { COLORREF Color; file.read(&Color, sizeof(Color)); SetTextColor(Color); break; } case META_SETWINDOWORG: { // Read the parameter. short Parms[2]; ASSERT(Record.rdSize == 5); file.read(Parms, sizeof(Parms)); m_DCState.m_cpWindowOrg.y = Parms[0]; m_DCState.m_cpWindowOrg.x = Parms[1]; NewSourceVars(); break; } case META_SETWINDOWEXT: { // Read the parameter. short Parms[2]; ASSERT(Record.rdSize == 5); file.read(Parms, sizeof(Parms)); m_DCState.m_cpWindowExt.y = Parms[0]; m_DCState.m_cpWindowExt.x = Parms[1]; NewSourceVars(); break; } case META_CREATEBRUSHINDIRECT: { CWMFBrushObject* pNewBrush = new CWMFBrushObject; file.read(&pNewBrush->m_LogBrush, sizeof(LOGBRUSH16)); NewObject(pNewBrush); break; } case META_DIBCREATEPATTERNBRUSH: { CWMFBrushObject* pNewBrush = new CWMFBrushObject; pNewBrush->m_LogBrush.lbStyle = BS_SOLID; pNewBrush->m_LogBrush.lbColor = RGB(128, 0, 0); NewObject(pNewBrush); break; } case META_CREATEPENINDIRECT: { CWMFPenObject* pNewPen = new CWMFPenObject; file.read(&pNewPen->m_LogPen, sizeof(LOGPEN16)); NewObject(pNewPen); // TRACE("New pen - s: %d; w: %d, %d; c: %08lx\n", // pNewPen->m_LogPen.lopnStyle, // pNewPen->m_LogPen.lopnWidth.x, // pNewPen->m_LogPen.lopnWidth.y, // pNewPen->m_LogPen.lopnColor); break; } case META_CREATEFONTINDIRECT: { CWMFFontObject* pNewFont = new CWMFFontObject; // Read the data. LOGFONT16 lf; file.read(&lf, sizeof(LOGFONT16)); // Translate it over. pNewFont->m_LogFont.lfHeight = lf.lfHeight; pNewFont->m_LogFont.lfWidth = lf.lfWidth; pNewFont->m_LogFont.lfEscapement = lf.lfEscapement; pNewFont->m_LogFont.lfOrientation = lf.lfOrientation; pNewFont->m_LogFont.lfWeight = lf.lfWeight; // Warning: hard-coded size ahead. memcpy(&pNewFont->m_LogFont.lfItalic, &lf.lfItalic, 8 + LF_FACESIZE); NewObject(pNewFont); break; } case META_CREATEPALETTE: { // This is mostly here to make sure the object array stays in sync. CWMFPaletteObject* pNewPalette = new CWMFPaletteObject; struct { WORD palVersion; WORD palNumEntries; } Header; file.read(&Header, sizeof(Header)); // Now we have the header. See how many entries we want. if (Header.palVersion == 0x0300) { int nPaletteSize = sizeof(PALETTEENTRY)*Header.palNumEntries; pNewPalette->m_pPalette = (LOGPALETTE*)new BYTE[sizeof(LOGPALETTE) + nPaletteSize - sizeof(PALETTEENTRY)]; pNewPalette->m_pPalette->palVersion = Header.palVersion; pNewPalette->m_pPalette->palNumEntries = Header.palNumEntries; file.read(pNewPalette->m_pPalette->palPalEntry, nPaletteSize); } NewObject(pNewPalette); break; } case META_CREATEREGION: { // This is mostly here to make sure the object array stays in sync. // I don't think there's hope of determining the parms format for // this record. CWMFRegionObject* pNewRegion = new CWMFRegionObject; NewObject(pNewRegion); break; } case META_SELECTPALETTE: case META_SELECTOBJECT: { short nIndex; file.read(&nIndex, sizeof(nIndex)); SelectObject(nIndex); // TRACE("SelectObject: %d\n", nIndex); break; } case META_DELETEOBJECT: { short nIndex; file.read(&nIndex, sizeof(nIndex)); DeleteObject(nIndex); // TRACE("DeleteObject: %d\n", nIndex); break; } case META_SETPOLYFILLMODE: { short nFillMode; file.read(&nFillMode, sizeof(nFillMode)); m_nFillMode = nFillMode; break; } case META_SETSTRETCHBLTMODE: { short nMode; file.read(&nMode, sizeof(nMode)); SetBltMode(nMode); break; } case META_POLYPOLYGON: { // Read the number of polygons. short nPolygons; file.read(&nPolygons, sizeof(nPolygons)); // Proceed to read counts and points (and draw). int* pCounts = NULL; POINT* pPoints = NULL; TRY { // Allocate the polygon counts. pCounts = new int[nPolygons]; // Read the polygon counts. int nPoints = 0; for (int nPolygon = 0; nPolygon < nPolygons; nPolygon++) { short p; file.read(&p, sizeof(p)); pCounts[nPolygon] = p; nPoints += p; } // Allocate the polygon points. pPoints = new POINT[nPoints]; // Read the polygon points. for (int nPoint = 0; nPoint < nPoints; nPoint++) { short p[2]; file.read(p, sizeof(p)); pPoints[nPoint].x = p[0]; pPoints[nPoint].y = p[1]; } // Draw the polypolygon. DrawPolyPolygon(pPoints, pCounts, nPolygons); } END_TRY delete [] pPoints; delete [] pCounts; fPrimitive = TRUE; break; } case META_POLYGON: { WORD wCount; file.read(&wCount, sizeof(wCount)); draw_polygon(wCount); fPrimitive = TRUE; break; } case META_POLYLINE: { WORD wCount; file.read(&wCount, sizeof(wCount)); draw_polyline(wCount, TRUE); fPrimitive = TRUE; break; } case META_ELLIPSE: { short Parms[4]; file.read(Parms, sizeof(Parms)); // Compute parameters to pass. // Parms[3] = left // Parms[2] = top // Parms[1] = right // Parms[0] = bottom OUTLINE_POINT center; center.x = (short)((int)Parms[3] + (int)Parms[1])/2; center.y = (short)((int)Parms[2] + (int)Parms[0])/2; short rx = Parms[3] - center.x; if (rx < 0) rx = -rx; short ry = Parms[2] - center.y; if (ry < 0) ry = -ry; draw_ellipse(center, rx, ry); fPrimitive = TRUE; break; } case META_ROUNDRECT: { // Cheat for now. Just draw it as a rectangle. // Skip the corner radii. file.seek(2*sizeof(short), ST_DEV_SEEK_CUR); // Fall through to... } case META_RECTANGLE: { short Parms[4]; file.read(Parms, sizeof(Parms)); // Parms[3] = left // Parms[2] = top // Parms[1] = right // Parms[0] = bottom OUTLINE_POINT p0, p1; p0.x = Parms[3]; p0.y = Parms[2]; p1.x = Parms[1]; p1.y = Parms[0]; draw_rectangle(p0, p1); fPrimitive = TRUE; break; } case META_DIBSTRETCHBLT: { // Read the numeric parameters. short Parms[10]; file.read(Parms, sizeof(Parms)); // Parms[0] = low-order word of raster op // Parms[1] = high-order word of raster op // Parms[2] = source y extent // Parms[3] = source x extent // Parms[4] = source y coordinate // Parms[5] = source x coordinate // Parms[6] = destination y extent // Parms[7] = destination x extent // Parms[8] = destination y coordinate // Parms[9] = destination x coordinate CRect crSource(CPoint(Parms[5], Parms[4]), CSize(Parms[3], Parms[2])); CRect crDest(CPoint(Parms[9], Parms[8]), CSize(Parms[7], Parms[6])); DWORD dwROP = MAKELONG(Parms[0], Parms[1]); // Process the rest of the dib blt. DoDibBlt(crSource, crDest, dwROP); fPrimitive = TRUE; break; } case META_DIBBITBLT: { // Read the numeric parameters. short Parms[7]; file.read(Parms, sizeof(Parms)); // Parms[0] = high-order word of raster op // Parms[1] = source y coordinate // Parms[2] = source x coordinate // Parms[3] = destination y extent // Parms[4] = destination x extent // Parms[5] = destination y coordinate // Parms[6] = destination x coordinate CRect crSource(CPoint(Parms[5], Parms[4]), CSize(Parms[7], Parms[6])); CRect crDest(CPoint(Parms[9], Parms[8]), CSize(Parms[7], Parms[6])); DWORD dwROP = MAKELONG(0, Parms[1]); // Process the rest of the dib blt. DoDibBlt(crSource, crDest, dwROP); fPrimitive = TRUE; break; } case META_STRETCHDIB: { // Read the numeric parameters. short Parms[11]; file.read(Parms, sizeof(Parms)); // Parms[0] = low-order word of raster op // Parms[1] = high-order word of raster op // Parms[2] = usage flag // Parms[3] = source y extent // Parms[4] = source x extent // Parms[5] = source y coordinate // Parms[6] = source x coordinate // Parms[7] = destination y extent // Parms[8] = destination x extent // Parms[9] = destination y coordinate // Parms[10] = destination x coordinate CRect crSource(CPoint(Parms[6], Parms[5]), CSize(Parms[4], Parms[3])); CRect crDest(CPoint(Parms[10], Parms[9]), CSize(Parms[8], Parms[7])); DWORD dwROP = MAKELONG(Parms[0], Parms[1]); WORD wUsage = (WORD)Parms[2]; // Process the rest of the dib blt. DoDibBlt(crSource, crDest, dwROP, wUsage); fPrimitive = TRUE; break; } case META_EXTTEXTOUT: { // Handle ExtTextOut call. // Read the numeric parameters. short Parms[4]; file.read(Parms, sizeof(Parms)); // Parms[0] = y // Parms[1] = x // Parms[2] = string length // Parms[3] = option flags RECTS rClip; if (Parms[3] != 0) { file.read(&rClip, sizeof(rClip)); } // String data follows int nStrLength = Parms[2]; int nStrSize = (nStrLength + 1) & ~1; LPBYTE pString = NULL; TRY { // Read the text. pString = new BYTE[nStrSize]; file.huge_read(pString, nStrSize); // See if there are any widths. ST_DEV_POSITION Here; file.tell(&Here); ST_DEV_POSITION lRecordEnd = lRecordOffset + Record.rdSize*sizeof(WORD); // TRACE("Count:%d; Here: %ld; lRecordEnd: %ld\n", // nStrLength, Here, lRecordEnd); int nDXSize = nStrLength*sizeof(short); short* pDX = NULL; if (lRecordEnd >= Here + nDXSize) { pDX = new short[nStrLength]; file.read(pDX, nDXSize); } OUTLINE_POINT p; p.x = (short)Parms[1]; p.y = (short)Parms[0]; RECT r; r.left = rClip.left; r.top = rClip.top; r.right = rClip.right; r.bottom = rClip.bottom; // Draw the text. DrawText(p, Parms[3], (LPCSTR)pString, nStrLength, &r, pDX); // Free the dx array. delete [] pDX; // Free the text. delete pString; } END_TRY fPrimitive = TRUE; break; } case META_TEXTOUT: { // Handle TextOut call. // Read the string size. short nStrLength; file.read(&nStrLength, sizeof(nStrLength)); int nStrSize = (nStrLength + 1) & ~1; LPBYTE pString = NULL; TRY { // Read the text. pString = new BYTE[nStrSize]; file.huge_read(pString, nStrSize); // Read the x and y. short Parms[2]; file.read(Parms, sizeof(Parms)); OUTLINE_POINT p; p.x = (short)Parms[1]; p.y = (short)Parms[0]; // Draw the text. DrawText(p, 0, (LPCSTR)pString, nStrLength, NULL); // Free the text. delete pString; } END_TRY fPrimitive = TRUE; break; } case META_MOVETO: case META_LINETO: { short Parms[2]; file.read(&Parms, sizeof(Parms)); // TRACE("%s: %d, %d\n", Record.rdFunction == META_MOVETO ? "MoveTo" : "LineTo", Parms[1], Parms[0]); OUTLINE_POINT p; p.x = Parms[1]; p.y = Parms[0]; if (Record.rdFunction == META_MOVETO) { // Move to. MoveTo(p); } else { // Must be Line to. LineTo(p); fPrimitive = TRUE; } break; } case META_PATBLT: { WORD Parms[6]; // Parms[0] - op low word // Parms[1] - op high word // Parms[2] - height // Parms[3] - width // Parms[4] - top // Parms[5] - left file.read(Parms, sizeof(Parms)); OUTLINE_POINT p0, p1; p0.x = Parms[5]; p0.y = Parms[4]; p1.x = p0.x + Parms[3]; p1.y = p0.y + Parms[2]; DoPatBlt(p0, p1, MAKELONG(Parms[0], Parms[1])); fPrimitive = TRUE; break; } case META_PIE: case META_ARC: { short Parms[8]; // Parms[0] = y4 end pt y // Parms[1] = x4 end pt x // Parms[2] = y3 start pt y // Parms[3] = x3 start pt x // Parms[4] = y2 Bound bottom // Parms[5] = x2 Bound right // Parms[6] = y1 Bound top // Parms[7] = x1 Bound left file.read(Parms, sizeof(Parms)); OUTLINE_POINT Center; Center.x = (short)midpoint(Parms[7], Parms[5]); Center.y = (short)midpoint(Parms[6], Parms[4]); double rx = Parms[5] - Center.x; if (rx < 0) rx = -rx; double ry = Parms[4] - Center.y; if (ry < 0) ry = -ry; double dStart = angle_from_vector(Parms[2] - Center.y, Parms[3] - Center.x); double dEnd = angle_from_vector(Parms[0] - Center.y, Parms[1] - Center.x); draw_elliptical_arc(Center, rx, ry, dStart-PI/2, dEnd-PI/2, (Record.rdFunction == META_PIE) ? 1 : -1); break; } case META_SAVEDC: { PushState(); break; } case META_RESTOREDC: { PopState(); break; } case META_SCALEVIEWPORTEXT: { // Read the parameter. short Parms[4]; // Parms[0] = ydenom // Parms[1] = ynum // Parms[2] = xdenom // Parms[3] = xnum file.read(Parms, sizeof(Parms)); m_DCState.m_cpViewportScaleNum.x = Parms[3]; m_DCState.m_cpViewportScaleDenom.x = Parms[2]; m_DCState.m_cpViewportScaleNum.y = Parms[1]; m_DCState.m_cpViewportScaleDenom.y = Parms[0]; NewSourceVars(); break; } default: { TRACE("UNKNOWN Record %d function: %04x, size: %08lx\n", m_nRecord, Record.rdFunction, Record.rdSize); break; } } m_nRecord++; // Seek past the record file.seek(lRecordOffset + Record.rdSize*sizeof(WORD), ST_DEV_SEEK_SET); *primitive = fPrimitive; return TRUE; }