Esempio n. 1
0
  ExcStatus SetParams(
    const ImageColorSpec&        colorSpec,
    const ImageSamplingGeometry& geometry)
  {
    ImageEnumSampling m_enumSampling;

    m_enumSampling = geometry.EnumSampling();

    if(JC_YCBCR == m_color && JC_GRAY == u2j_cmap[colorSpec.EnumColorSpace()])
      m_nchannels = 1;

    m_color     = u2j_cmap[colorSpec.EnumColorSpace()];
    m_sampling  = u2j_smap[m_enumSampling];
    m_precision = colorSpec.DataRange()[0].BitDepth() + 1;

    m_size.width  = geometry.RefGridRect().Width();
    m_size.height = geometry.RefGridRect().Height();

    return ExcStatusOk;
  } // JPEGDecoder::SetParams()
Esempio n. 2
0
IM_ERROR ReadImageBMP(
  BaseStreamInput& in,
  PARAMS_BMP&,
  CIppImage&       image)
{
  int                   i;
  Image                 imageCn;
  IppiSize              roi;
  ImageDataPtr          dataPtr;
  ImageDataOrder        dataOrder;
  ImageColorSpec        colorSpec;
  ImageSamplingGeometry geometry;

  BMPDecoder decoder;

  if(ExcStatusOk != decoder.Init())
    return IE_INIT;

  if(ExcStatusOk != decoder.AttachStream(in))
    return IE_ASTREAM;

  if(ExcStatusOk != decoder.ReadHeader(colorSpec,geometry))
    return IE_RHEADER;

  int nOfComponents = geometry.NOfComponents();

  dataOrder.SetDataType(T8u);

  dataOrder.ReAlloc(Interleaved, nOfComponents);
  dataOrder.PixelStep()[0] = nOfComponents;
  dataOrder.LineStep() [0] = geometry.RefGridRect().Width() * nOfComponents + BYTES_PAD(geometry.RefGridRect().Width(), nOfComponents, 1);

  imageCn.ColorSpec().ReAlloc(nOfComponents);
  imageCn.ColorSpec().SetColorSpecMethod(Enumerated);
  imageCn.ColorSpec().SetComponentToColorMap(Direct);

  for(i = 0; i < nOfComponents; i++)
   imageCn.ColorSpec().DataRange()[i].SetAsRange8u(255);

  ImageEnumColorSpace in_color;
  ImageEnumColorSpace out_color;
  in_color  = colorSpec.EnumColorSpace();
  out_color = in_color;

  imageCn.ColorSpec().SetEnumColorSpace(out_color);
  image.Color((IM_COLOR)image.UicToIppColor(out_color));

  roi.width  = geometry.RefGridRect().Width();
  roi.height = geometry.RefGridRect().Height();

  if(0 != image.Alloc(roi,nOfComponents,8,1))
    return IE_ALLOC;

  dataPtr.p8u = image;

  imageCn.Buffer().Attach(&dataPtr,dataOrder,geometry);

  if(ExcStatusOk != decoder.ReadData(imageCn.Buffer().DataPtr(),dataOrder))
    return IE_RDATA;

  return IE_OK;
} // ReadImageBMP()