diff --git a/software_scale_context.go b/software_scale_context.go index bf76c83..d6701ca 100644 --- a/software_scale_context.go +++ b/software_scale_context.go @@ -91,20 +91,12 @@ func (ssc *SoftwareScaleContext) DestinationPixelFormat() PixelFormat { return PixelFormat(ssc.dstFormat) } -func (ssc *SoftwareScaleContext) DestinationWidth() int { - return int(ssc.dstW) -} - -func (ssc *SoftwareScaleContext) SourceHeight() int { - return int(ssc.srcH) -} - -func (ssc *SoftwareScaleContext) SourcePixelFormat() PixelFormat { - return PixelFormat(ssc.srcFormat) +func (ssc *SoftwareScaleContext) DestinationResolution() (int, int) { + return int(ssc.dstW), int(ssc.dstH) } -func (ssc *SoftwareScaleContext) SourceWidth() int { - return int(ssc.srcW) +func (ssc *SoftwareScaleContext) DestinationWidth() int { + return int(ssc.dstW) } func (ssc *SoftwareScaleContext) Flags() SoftwareScaleContextFlags { @@ -121,11 +113,21 @@ func (ssc *SoftwareScaleContext) SetDestinationPixelFormat(p PixelFormat) error return ssc.updateContext() } +func (ssc *SoftwareScaleContext) SetDestinationResolution(w int, h int) error { + ssc.dstW = C.int(w) + ssc.dstH = C.int(h) + return ssc.updateContext() +} + func (ssc *SoftwareScaleContext) SetDestinationWidth(i int) error { ssc.dstW = C.int(i) return ssc.updateContext() } +func (ssc *SoftwareScaleContext) SetFlags(swscf SoftwareScaleContextFlags) { + ssc.flags = swscf +} + func (ssc *SoftwareScaleContext) SetSourceHeight(i int) error { ssc.srcH = C.int(i) return ssc.updateContext() @@ -136,13 +138,31 @@ func (ssc *SoftwareScaleContext) SetSourcePixelFormat(p PixelFormat) error { return ssc.updateContext() } +func (ssc *SoftwareScaleContext) SetSourceResolution(w int, h int) error { + ssc.srcW = C.int(w) + ssc.srcH = C.int(h) + return ssc.updateContext() +} + func (ssc *SoftwareScaleContext) SetSourceWidth(i int) error { ssc.srcW = C.int(i) return ssc.updateContext() } -func (ssc *SoftwareScaleContext) SetFlags(swscf SoftwareScaleContextFlags) { - ssc.flags = swscf +func (ssc *SoftwareScaleContext) SourceHeight() int { + return int(ssc.srcH) +} + +func (ssc *SoftwareScaleContext) SourcePixelFormat() PixelFormat { + return PixelFormat(ssc.srcFormat) +} + +func (ssc *SoftwareScaleContext) SourceResolution() (int, int) { + return int(ssc.srcW), int(ssc.srcH) +} + +func (ssc *SoftwareScaleContext) SourceWidth() int { + return int(ssc.srcW) } func (sc *SoftwareScaleContext) Free() { diff --git a/software_scale_context_test.go b/software_scale_context_test.go index 4935566..d25d592 100644 --- a/software_scale_context_test.go +++ b/software_scale_context_test.go @@ -90,5 +90,15 @@ func TestSoftwareScaleContext(t *testing.T) { _, ycbcrOk := i2.(*image.YCbCr) require.True(t, ycbcrOk) + require.NoError(t, swsc.SetDestinationResolution(640, 480)) + w, h := swsc.DestinationResolution() + require.Equal(t, w, 640) + require.Equal(t, h, 480) + + require.NoError(t, swsc.SetSourceResolution(480, 270)) + w, h = swsc.SourceResolution() + require.Equal(t, w, 480) + require.Equal(t, h, 270) + defer swsc.Free() }