当前位置: 首页>>代码示例>>C++>>正文


C++ Layer::Bitmap方法代码示例

本文整理汇总了C++中Layer::Bitmap方法的典型用法代码示例。如果您正苦于以下问题:C++ Layer::Bitmap方法的具体用法?C++ Layer::Bitmap怎么用?C++ Layer::Bitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Layer的用法示例。


在下文中一共展示了Layer::Bitmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Layer

Layer*
Layer::readLayerOldStyle(BFile& file, ImageView* imageView, int32 new_id)
{
//	// Layer has stored the following things:
//	//	1.	Layer frame (i.e. the frame of bitmap)
//	//	2.	Layer id
//	//	3.	Layer type
//	//	4.	Layer visibility
//	//	5.	Bitmap data
//	//

    BRect layer_frame;
    if (file.Read(&layer_frame,sizeof(BRect)) != sizeof(BRect))
        return NULL;

    // The layer id is written to the file, so it must be read also, but it will
    // not be used. Instead we use the id that is provided as a parameter
    int32 id;	// This is not actually used.
    if (file.Read(&id,sizeof(uint32)) != sizeof(uint32))
        return NULL;
    id = B_BENDIAN_TO_HOST_INT32(id);

    layer_type layerType;
    if ((file.Read(&layerType, sizeof(uint32)) != sizeof(uint32)))
        return NULL;

    bool visi;
    if (file.Read(&visi,sizeof(bool)) != sizeof(bool))
        return NULL;

    // Old files project-files are all big-endian so we convert data here.
    layer_frame.left = B_BENDIAN_TO_HOST_FLOAT(layer_frame.left);
    layer_frame.right = B_BENDIAN_TO_HOST_FLOAT(layer_frame.right);
    layer_frame.top = B_BENDIAN_TO_HOST_FLOAT(layer_frame.top);
    layer_frame.bottom = B_BENDIAN_TO_HOST_FLOAT(layer_frame.bottom);

    layerType =layer_type(B_BENDIAN_TO_HOST_INT32(layerType));
    if (layerType != HS_NORMAL_LAYER)
        return NULL;

    // Create the layer
    Layer* layer = new Layer(layer_frame, new_id, imageView, layerType);
    layer->SetVisibility(visi);

    int8* bits = (int8*)layer->Bitmap()->Bits();
    // align the file pointer to four-byte boundary.
    int32 alignment_offset;
    alignment_offset = (4 - (file.Position() % 4)) % 4;

    if (file.Read(bits,alignment_offset) != alignment_offset) {
        delete layer;
        return NULL;
    }
    bits += alignment_offset;


    if (file.Read(bits,layer->Bitmap()->BitsLength()-alignment_offset)
            != (layer->Bitmap()->BitsLength()-alignment_offset)) {
        delete layer;
        return NULL;
    }
    // Before returning calculate the layer's miniature image.
    layer->calc_mini_image();
    return layer;
}
开发者ID:puckipedia,项目名称:ArtPaint,代码行数:65,代码来源:Layer.cpp


注:本文中的Layer::Bitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。