本文整理汇总了C++中Fl_Image类的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Image类的具体用法?C++ Fl_Image怎么用?C++ Fl_Image使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fl_Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bg_image_input
void bg_image_input(Fl_Input *w, void *d)
{
changed=true;
Fl_String val(w->value());
filename = fl_file_expand(val);
if(mini_wpaper) { delete mini_wpaper; mini_wpaper=0; }
if(mini_image) { delete mini_image; mini_image=0; }
Fl_Image *im = Fl_Image::read(filename);
if(im) {
im->system_convert();
float scalew = (float)mini_image_box->w()/(float)desktop->w();
float scaleh = (float)mini_image_box->h()/(float)desktop->h();
mini_image = im->scale(int(im->width()*scalew), int(im->height()*scaleh));
delete im;
}
if(mini_image) {
mini_wpaper = make_image(color, mini_image,
mini_image_box->w(), mini_image_box->h(),
mode, opacity);
mini_image_box->image(mini_wpaper);
} else {
mini_image_box->image(0);
}
image_input->value(filename);
image_input->redraw();
mini_image_box->redraw();
}
示例2: path
void Icon::update_icon()
{
if(icon_im) delete icon_im;
Fl_String path(PREFIX"/share/ede/icons/48x48/");
path += icon_file;
if(!fl_file_exists(path)) path = icon_file;
if(fl_file_exists(path))
{
icon_im = Fl_Image::read(path, 0);
} else {
icon_im = 0;
}
if(!icon_im) {
icon_im = Fl_Image::read(PREFIX"/share/ede/icons/48x48/folder.png", 0);
}
if(icon_im) {
if(icon_im->width()!=48 || icon_im->height()!=48) {
Fl_Image *old = icon_im;
icon_im = old->scale(48,48);
delete old;
}
icon_im->mask_type(MASK_ALPHA);
icon_im->threshold(128);
}
}
示例3: w
void Flcc_ValueBox::generate()
{
int X = 0, Y = 0, W = w(), H = h();
box()->inset(X,Y,W,H);
Fl_Image *im = new Fl_Image(W, H, 32);
uint32 *dst = (uint32*)im->data();
uint32 rgb;
int skip = (im->pitch() - W * im->bytespp()) >> 2;
for(int y = 0; y < H; y++) {
float Yf = 255*(1.0-float(y)/H);
fl_rgb888_from_rgb(rgb, uchar(tr*Yf+.5f), uchar(tg*Yf+.5f), uchar(tb*Yf+.5f));
for(int x = 0; x < W; x++) {
*dst++ = rgb;
}
dst += skip;
}
if(bg) delete bg;
bg = im;
}
示例4: fclose
void DerivedShared_Image::reload ()
{
int i;
FILE * fp;
uchar header[64];
Fl_Image * img;
if (!name_)
return;
if ((fp = fl_fopen (name_, "rb")) != NULL)
{
if (fread (header, 1, sizeof (header), fp) == 0)
{ /* ignore */
}
fclose (fp);
}
else
{
return;
}
if (memcmp (header, "#define", 7) == 0) // XBM file
img = new Fl_XBM_Image (name_);
else if (memcmp (header, "/* XPM */", 9) == 0) // XPM file
img = new Fl_XPM_Image (name_);
else
{
for (i = 0, img = 0; i < num_handlers_; i++)
{
// The only difference is the cast
img = (static_cast<Fl_Image *> (
(fl_handlers_[i]) (name_, header, sizeof (header))));
if (img)
break;
}
}
if (img)
{
if (alloc_image_)
delete image_;
alloc_image_ = 1;
if ((img->w () != w () && w ()) || (img->h () != h () && h ()))
{
Fl_Image * temp = img->copy (w (), h ());
delete img;
image_ = temp;
}
else
{
image_ = img;
}
update ();
}
};
示例5: desktop_properties
void desktop_properties(Fl_Widget *, void *arg)
{
if(!shown) {
make_desktop_properties();
shown = true;
}
mode = desktop->bg_mode;
color = desktop->bg_color;
opacity = desktop->bg_opacity;
use = desktop->bg_use;
filename = desktop->bg_filename;
if(bg_prop_window->visible()) {
bg_prop_window->show();
return;
}
if(mini_image) { delete mini_image; mini_image=0; }
if(mini_wpaper){ delete mini_wpaper; mini_wpaper=0;}
color_button->selection_color(color);
mini_image_box->color(color);
opacity_slider->value(opacity);
mode_choice->value(mode);
use_button->value(use);
image_input->value(filename);
if(!desktop->bg_filename.empty())
{
Fl_Image *im = Fl_Image::read(desktop->bg_filename);
if(im) {
im->system_convert();
float scalew = (float)mini_image_box->w()/(float)desktop->w();
float scaleh = (float)mini_image_box->h()/(float)desktop->h();
mini_image = im->scale(int(im->width()*scalew), int(im->height()*scaleh));
delete im;
}
}
if(mini_image) {
mini_wpaper = make_image(color, mini_image,
mini_image_box->w(), mini_image_box->h(),
mode, opacity);
mini_image_box->image(mini_wpaper);
} else
mini_image_box->image(0);
if(use)
bg_image_group->activate();
else {
bg_image_group->deactivate();
mini_image_box->image(0);
}
bg_prop_window->show();
}
示例6: draw_box
void
Panner::draw_the_box ( int tx, int ty, int tw, int th )
{
draw_box();
Fl_Image *i = 0;
if ( _bg_image && ( _bg_image->h() != th || projection() != _bg_image_projection ) )
{
if ( _bg_image_scaled )
delete _bg_image;
else
((Fl_Shared_Image*)_bg_image)->release();
_bg_image = 0;
}
if ( ! _bg_image )
{
if ( projection() == POLAR )
{
if ( th <= 92 )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-92x92.png" );
else if ( th <= 502 )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-502x502.png" );
else if ( th <= 802 )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-802x802.png" );
}
else
{
if ( th <= 92 )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-92x92.png" );
else if ( th <= 502 )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-502x502.png" );
else if ( th <= 802 )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-802x802.png" );
}
if ( i && i->h() != th )
{
Fl_Image *scaled = i->copy( th, th );
_bg_image = scaled;
_bg_image_scaled = true;
}
else
{
_bg_image = i;
_bg_image_scaled = false;
}
}
_bg_image_projection = projection();
if ( _bg_image )
_bg_image->draw( tx, ty );
}
示例7: TEST
// Tests Open SLImage
TEST(ImageControllerTest, loadSLImageWithImageController) {
ImageController imageController;
imageController.open(filename);
Fl_Image * image = imageController.getCurrentImage();
ASSERT_NE((void *)NULL, image ) << "File did not open " << filename;
EXPECT_EQ(30, image->w());
EXPECT_EQ(30, image->h());
EXPECT_EQ(3, image->d());
EXPECT_EQ(92, image->ld()); //4 byte aligned under OpenCV not under FLTK
}
示例8: r
Fl_Image *Fl_Image_Filter::apply_to_new(Fl_Image *image, Fl_Rect *rect, Fl_Image_Filter *filter, float val1, float val2, float val3)
{
Fl_Rect r(0,0,image->width(),image->height());
if(!rect) { rect = &r; }
Fl_Image *ret = new Fl_Image(*image);
uint8 *data = ret->data();
if(!filter->execute(&data, *rect, ret->pitch(), ret->format(), val1, val2, val3)) {
delete ret;
return 0;
}
return ret;
}
示例9: draw
void draw() {
if(!(damage()&FL_DAMAGE_ALL)) return;
int X=0,Y=0,W=w(),H=h();
box()->inset(X,Y,W,H);
if(image()) {
draw_frame();
fl_push_clip(X,Y,W,H);
Fl_Image *im = image();
W=im->width();
H=im->height();
int pbw = w() - 10;
int pbh = h() - 10;
if(W > pbw || H > pbh) {
W = pbw;
H = W * im->height() / im->width();
if(H > pbh) {
H = pbh;
W = H * im->width() / im->height();
}
}
X=(w()/2)-W/2;
Y=(h()/2)-H/2;
if(X<5) X=5;
if(Y<5) Y=5;
im->mask_type(MASK_NONE);
im->draw(X,Y,W,H,FL_ALIGN_SCALE);
fl_clip_out(X,Y,W,H);
X=0,Y=0,W=w(),H=h();
box()->inset(X,Y,W,H);
fl_color(color());
fl_rectf(X,Y,W,H);
fl_pop_clip();
} else {
draw_box();
if(w()<=120) label_size(8);
if(w()>120) label_size(10);
if(w()>180) label_size(12);
if(w()>250) label_size(14);
if(label()[0]=='?'&&label()[1]=='\0') label_size(100);
draw_label(X, Y, W, H, align());
}
}
示例10: FltkImage
FltkImage * FltkImage::load(char const * filename) const {
if (SLStringUtil::empty(filename))
return 0;
Fl_Shared_Image *sharedImage = Fl_Shared_Image::get(filename);
Fl_Image * image = sharedImage->copy();
sharedImage->release();
if ( image->h() == 0 ) {
delete image;
return 0;
}
FltkImage * result = new FltkImage(image);
result->setFilename(filename);
return result;
}
示例11: Fl_Image
Fl_Image *make_bg(int w, int h)
{
#ifdef GENERATE_16BIT
Fl_Image *ret = new Fl_Image(w, h, 16, 0, true, 0x0000F000, 0x00000F00, 0x000000F0, 0x0000000F);
#else
Fl_Image *ret = new Fl_Image(w, h, 32, 0, true, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
#endif
printf("BG Format:\n Rmask: 0x%08x\n Gmask: 0x%08x\n Bmask: 0x%08x\n", ret->format()->Rmask, ret->format()->Gmask, ret->format()->Bmask);
// pitch = WORD alignment bits per line
int pitch=Fl_Renderer::calc_pitch(ret->format()->bytespp, w);
int skip = pitch - w * ret->format()->bytespp;
uint8 *p = ret->data();
uint8 r,g,b;
for (int y = 0; y < h; y++) {
double Y = double(y)/(h-1);
for (int x = 0; x < w; x++) {
double X = double(x)/(w-1);
r = uchar(255*((1-X)*(1-Y))); // red in upper-left
g = uchar(255*((1-X)*Y)); // green in lower-left
b = uchar(255*(X*Y)); // blue in lower-right
fl_assemble_rgb(p,
ret->format()->bytespp, ret->format(),
r, g, b);
p+=ret->format()->bytespp;
}
p+=skip;
}
return ret;
}
示例12: Fl_Image
Fl_Image *Fl_Image::scale(int W, int H)
{
Fl_Image *ret = new Fl_Image(W, H, bitspp());
ret->format()->copy(format());
Fl_Rect olds(0,0,width(),height()); Fl_Rect news(0,0,W,H);
bool success = Fl_Renderer::stretch(m_data, bytespp(), pitch(), &olds,
ret->data(), bytespp(), ret->pitch(), &news);
if(!success) {
delete ret;
ret = 0;
}
return ret;
}
示例13: Fl_Window
MovableIcon::MovableIcon(Icon *i)
: Fl_Window(desktop->x()+i->x(), desktop->y()+i->y(), i->w(), i->h())
{
icon = i;
set_override();
create();
Fl_Image *im = i->icon_im;
if(im)
{
Pixmap mask = im->create_mask(im->width(), im->height());
XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0, mask, ShapeSet);
align(FL_ALIGN_INSIDE);
image(im);
}
}
示例14: Fl_Window
MovableIcon::MovableIcon(Icon* i) : Fl_Window(i->x(), i->y(), i->w(), i->h()), icon(i)
{
assert(icon != NULL);
set_override();
create();
Fl_Image* img = icon->icon_image();
if(img)
{
#ifdef SHAPE
Pixmap mask = img->create_mask(img->width(), img->height());
XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0, mask, ShapeSet);
#endif
align(FL_ALIGN_INSIDE);
image(img);
}
}
示例15: draw
void Icon::draw()
{
Fl_Flags f=0;
Fl_Image *im = icon_im;
if(focused()) {
f=FL_SELECTED;
}
if(im)
im->draw(0, 0, w(), h(),f);
else {
fl_color(FL_RED);
fl_rect(0,0,w(),h());
fl_color(FL_BLACK);
fl_rectf(1,1,w()-2,h()-2);
fl_color(FL_WHITE);
fl_font(label_font()->bold(), 10);
fl_draw("NO ICON FOUND!", 1, 1, w()-2, h()-2, FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_WRAP);
}
int X = w()-(w()/2)-(lwidth/2);
int Y = h()+2;
if(!label_trans) {
fl_color(label_background);
fl_rectf(X,Y,lwidth,lheight);
}
if(focused()) {
focus_box()->draw(X, Y, lwidth, lheight, color(), 0);
}
fl_font(label_font(), label_size());
// A little shadow, from Dejan's request :)
// SUCKS!
/*fl_color(fl_darker(label_color()));
fl_draw(label(), X-1, Y+1, lwidth, lheight, flags());
fl_draw(label(), X, Y+1, lwidth, lheight, flags());
*/
fl_color(label_color());
fl_draw(label(), X, Y, lwidth, lheight, flags());
}