diff --git a/renderservice/android/app.png b/renderservice/android/app.png new file mode 100644 index 0000000..3e2465d Binary files /dev/null and b/renderservice/android/app.png differ diff --git a/renderservice/android/base.png b/renderservice/android/base.png new file mode 100644 index 0000000..766a15e Binary files /dev/null and b/renderservice/android/base.png differ diff --git a/renderservice/android/bottomshit.png b/renderservice/android/bottomshit.png new file mode 100644 index 0000000..0d50276 Binary files /dev/null and b/renderservice/android/bottomshit.png differ diff --git a/renderservice/android/close.png b/renderservice/android/close.png new file mode 100644 index 0000000..9434cfa Binary files /dev/null and b/renderservice/android/close.png differ diff --git a/renderservice/android/code.png b/renderservice/android/code.png new file mode 100644 index 0000000..a8a8125 Binary files /dev/null and b/renderservice/android/code.png differ diff --git a/renderservice/android/kurvendingopenrechts.png b/renderservice/android/kurvendingopenrechts.png new file mode 100644 index 0000000..145110d Binary files /dev/null and b/renderservice/android/kurvendingopenrechts.png differ diff --git a/renderservice/android/lilading.png b/renderservice/android/lilading.png new file mode 100644 index 0000000..1631a4b Binary files /dev/null and b/renderservice/android/lilading.png differ diff --git a/renderservice/android/middleleftthingy.png b/renderservice/android/middleleftthingy.png new file mode 100644 index 0000000..4a97bcb Binary files /dev/null and b/renderservice/android/middleleftthingy.png differ diff --git a/renderservice/android/middlelogo.png b/renderservice/android/middlelogo.png new file mode 100644 index 0000000..e2e08d3 Binary files /dev/null and b/renderservice/android/middlelogo.png differ diff --git a/renderservice/android/navbar.png b/renderservice/android/navbar.png new file mode 100644 index 0000000..91a98f5 Binary files /dev/null and b/renderservice/android/navbar.png differ diff --git a/renderservice/android/statusbarright.png b/renderservice/android/statusbarright.png new file mode 100644 index 0000000..6dbcfac Binary files /dev/null and b/renderservice/android/statusbarright.png differ diff --git a/renderservice/index.js b/renderservice/index.js index 8c02448..f352e09 100644 --- a/renderservice/index.js +++ b/renderservice/index.js @@ -19,13 +19,11 @@ microService * Putting the QR Code into a Screenshot */ .post('/qrcode', async (req, res) => { - const returnImage = !!req.body.ios - ? IOSAppImg.clone() - : AndroidAppImg.clone(); const qrCodeImage = await Jimp.read(Buffer.from(req.body.QrCode, 'base64')) await qrCodeImage.crop(37, 37, 165, 165) - if (!!req.body.ios) { + if (!!req.body.ios_deprecated) { + const returnImage = IOSAppImg.clone() /* 198, 635 397, 835 @@ -42,22 +40,127 @@ microService 591, 915 - 868 ); + res.set('Content-Type', 'image/png') + return res.send(await returnImage.getBufferAsync('image/png')) } else { - await qrCodeImage.resize(421, 421, Jimp.RESIZE_NEAREST_NEIGHBOR) - await returnImage.composite(qrCodeImage, 329, 780) - const font = await Jimp.loadFont(Jimp.FONT_SANS_128_BLACK) - await returnImage.print(font, 0, 1212, + const screenWidth = req.body.screenWidth || 666 + const screenHeight = req.body.screenHeight || 1080 + + let BaseAppImg = await Jimp.read('./android/base.png') + const returnImage = BaseAppImg.clone() + await returnImage.resize(screenWidth, screenHeight) + let CropTop = 0 + let CropBottom = 0 + let globalY = 0 + { // Statuszeile + const CStatusBarHeight = (screenHeight / 2220) * 63 + CropTop = CStatusBarHeight + for (const { x, y } of returnImage.scanIterator(0, 0, screenWidth, CStatusBarHeight)) + await returnImage.setPixelColor(0x2f2f2fff, x, y) + const statusBarImage = await Jimp.read('./android/statusbarright.png') + await statusBarImage.resize(Jimp.AUTO, CStatusBarHeight, Jimp.RESIZE_NEAREST_NEIGHBOR) + await returnImage.composite(statusBarImage, (screenWidth - statusBarImage.bitmap.width) - 25, 0) + globalY += CStatusBarHeight + } + { // Obere Zeile mit MCDLogo und dem Pfeil + const CFirstBarHeight = (screenHeight / 2220) * 126 + const CFirstBarLineWidth = Math.round((screenHeight / 2220) * 3) + for (const { x, y } of returnImage.scanIterator(0, globalY, screenWidth, CFirstBarHeight)) + await returnImage.setPixelColor( + (CFirstBarLineWidth <= (CFirstBarHeight - (y - globalY))) + ? 0x666666ff + : 0x585858ff, + x, y) + const firstBarLeftImage = await Jimp.read('./android/middleleftthingy.png') + await firstBarLeftImage.resize(Jimp.AUTO, CFirstBarHeight - CFirstBarLineWidth, Jimp.RESIZE_NEAREST_NEIGHBOR) + await returnImage.composite(firstBarLeftImage, 25, globalY) + const firstBarCenterImage = await Jimp.read('./android/middlelogo.png') + await firstBarCenterImage.resize(Jimp.AUTO, CFirstBarHeight - CFirstBarLineWidth, Jimp.RESIZE_NEAREST_NEIGHBOR) + await returnImage.composite(firstBarCenterImage, (screenWidth - firstBarCenterImage.bitmap.width) / 2, globalY) + globalY += CFirstBarHeight + } + { // Navigationsleiste + const CNavBarHeight = (screenHeight / 2220) * 120 + CropBottom = CNavBarHeight + for (const { x, y } of returnImage.scanIterator(0, screenHeight - CNavBarHeight, screenWidth, CNavBarHeight)) + await returnImage.setPixelColor(0x616161ff, x, y) + const navBarImage = await Jimp.read('./android/navbar.png') + await navBarImage.resize(Jimp.AUTO, CNavBarHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(navBarImage, (screenWidth - navBarImage.bitmap.width) / 2, screenHeight - CNavBarHeight) + globalY += CNavBarHeight + } + { // Coupon Ding + const Padding = (screenHeight / 2220) * 65 + globalY += Padding + const CNavBarHeight = (screenHeight / 2220) * 503 + const CCouponEckeHeight = (screenHeight / 2220) * 16 + const CCouponLineWidth = Math.round((screenHeight / 2220) * 5) + const CCouponBoxWidth = (screenWidth / 1220) * 1090 + for (const { x, y } of returnImage.scanIterator((screenWidth - CCouponBoxWidth) / 2, globalY, CCouponBoxWidth, CCouponLineWidth)) + await returnImage.setPixelColor(0x5c5c5cff, x, y) + const lilaDingImage = await Jimp.read('./android/lilading.png') + await lilaDingImage.resize(Jimp.AUTO, CNavBarHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(lilaDingImage, ((screenWidth - CCouponBoxWidth) / 2) - lilaDingImage.bitmap.width, globalY) + const couponEckeImage = await Jimp.read('./android/kurvendingopenrechts.png') + await couponEckeImage.resize(Jimp.AUTO, CCouponEckeHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(couponEckeImage, ((screenWidth - CCouponBoxWidth) / 2) + CCouponBoxWidth, globalY) + for (const { x, y } of returnImage.scanIterator(((screenWidth - CCouponBoxWidth) / 2) + CCouponBoxWidth + couponEckeImage.bitmap.width - CCouponLineWidth, globalY + couponEckeImage.bitmap.height, CCouponLineWidth, lilaDingImage.bitmap.height)) + await returnImage.setPixelColor(0x5c5c5cff, x, y) + } + { // QRCodeBox + const CQrCodeBoxWidth = (screenWidth / 1220) * 996 + const CQrCodeBoxHeight = (screenHeight / 2220) * 1220 + const CQrCodeScanTextHeight = (screenHeight / 2220) * 168 + const CQrCodeCloseHeight = (screenHeight / 2220) * 45 + globalY = (screenHeight - CQrCodeBoxHeight) / 2 + for (const { x, y } of returnImage.scanIterator((screenWidth - CQrCodeBoxWidth) / 2, (screenHeight - CQrCodeBoxHeight) / 2, CQrCodeBoxWidth, CQrCodeBoxHeight)) + await returnImage.setPixelColor(0xffffffff, x, y) + const closeImage = await Jimp.read('./android/close.png') + await closeImage.resize(Jimp.AUTO, CQrCodeCloseHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(closeImage, + ((screenWidth + CQrCodeBoxWidth) / 2) - closeImage.bitmap.width * 2, + ((screenHeight - CQrCodeBoxHeight) / 2) + closeImage.bitmap.height + ) + const scanCodeImage = await Jimp.read('./android/code.png') + await scanCodeImage.resize(Jimp.AUTO, CQrCodeScanTextHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(scanCodeImage, + ((screenWidth - scanCodeImage.bitmap.width) / 2), + ((screenHeight - CQrCodeBoxHeight / 1.5) / 2) + ) + globalY += CQrCodeBoxHeight + } + { // Bottomshit + const Padding = (screenHeight / 2220) * 60 + globalY += Padding + const CBottomShitHeight = (screenHeight / 2220) * 103 + const CBottomShitLineWidth = Math.round((screenHeight / 2220) * 5) + const bottomShitImage = await Jimp.read('./android/bottomshit.png') + await bottomShitImage.resize(Jimp.AUTO, CBottomShitHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(bottomShitImage, (screenWidth - bottomShitImage.bitmap.width) / 2, globalY) + globalY += CBottomShitHeight + for (const { x, y } of returnImage.scanIterator(0, globalY, screenWidth, CBottomShitLineWidth)) + await returnImage.setPixelColor(0x585858ff, x, y) + } + const CQrCodeImageWidth = (screenWidth / 1220) * 464 + const CQrCodeImageHeight = (screenHeight / 2220) * 464 + const CQrCodeTextHeight = (screenHeight / 2220) * 72 + await qrCodeImage.resize(CQrCodeImageWidth, CQrCodeImageWidth, Jimp.RESIZE_NEAREST_NEIGHBOR) + await returnImage.composite(qrCodeImage, (screenWidth - CQrCodeImageWidth) / 2, (screenHeight - CQrCodeImageHeight) / 2) + const font = await Jimp.loadFont(Jimp.FONT_SANS_64_BLACK) + await returnImage.print(font, 0, ((screenHeight - CQrCodeImageHeight) / 2) + CQrCodeImageHeight + CQrCodeTextHeight, { text: req.body.RandomCode, alignmentX: Jimp.HORIZONTAL_ALIGN_CENTER, alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE }, - 1080, - 146 + screenWidth, + CQrCodeTextHeight ); + CropTop = 0 + await returnImage.crop(0, CropTop, screenWidth, screenHeight - (CropTop + CropBottom)) + res.set('Content-Type', 'image/png') + return res.send(await returnImage.getBufferAsync('image/png')) } - res.set('Content-Type', 'image/png') - return res.send(await returnImage.getBufferAsync('image/png')) }) /** * Putting the Offer Pics into a single Image diff --git a/renderservice/ios/app.png b/renderservice/ios/app.png new file mode 100644 index 0000000..a52faff Binary files /dev/null and b/renderservice/ios/app.png differ diff --git a/renderservice/newcomp.js b/renderservice/newcomp.js new file mode 100644 index 0000000..e6cce8c --- /dev/null +++ b/renderservice/newcomp.js @@ -0,0 +1,100 @@ + +const Jimp = require('jimp') +let test = async () => { + //const screenWidth = 1220, screenHeight = 2220 + const screenWidth = 666, screenHeight = 1080 + let BaseAppImg = await Jimp.read('./android/base.png') + const returnImage = BaseAppImg.clone() + await returnImage.resize(screenWidth, screenHeight) + let globalY = 0 + { // Statuszeile + const CStatusBarHeight = (screenHeight / 2220) * 63 + for (const { x, y } of returnImage.scanIterator(0, 0, screenWidth, CStatusBarHeight)) + await returnImage.setPixelColor(0x2f2f2fff, x, y) + const statusBarImage = await Jimp.read('./android/statusbarright.png') + await statusBarImage.resize(Jimp.AUTO, CStatusBarHeight, Jimp.RESIZE_NEAREST_NEIGHBOR) + await returnImage.composite(statusBarImage, (screenWidth - statusBarImage.bitmap.width) - 25, 0) + globalY += CStatusBarHeight + } + { // Obere Zeile mit MCDLogo und dem Pfeil + const CFirstBarHeight = (screenHeight / 2220) * 126 + const CFirstBarLineWidth = Math.round((screenHeight / 2220) * 3) + for (const { x, y } of returnImage.scanIterator(0, globalY, screenWidth, CFirstBarHeight)) + await returnImage.setPixelColor( + (CFirstBarLineWidth <= (CFirstBarHeight - (y - globalY))) + ? 0x666666ff + : 0x585858ff, + x, y) + const firstBarLeftImage = await Jimp.read('./android/middleleftthingy.png') + await firstBarLeftImage.resize(Jimp.AUTO, CFirstBarHeight - CFirstBarLineWidth, Jimp.RESIZE_NEAREST_NEIGHBOR) + await returnImage.composite(firstBarLeftImage, 25, globalY) + const firstBarCenterImage = await Jimp.read('./android/middlelogo.png') + await firstBarCenterImage.resize(Jimp.AUTO, CFirstBarHeight - CFirstBarLineWidth, Jimp.RESIZE_NEAREST_NEIGHBOR) + await returnImage.composite(firstBarCenterImage, (screenWidth - firstBarCenterImage.bitmap.width) / 2, globalY) + globalY += CFirstBarHeight + } + { // Navigationsleiste + const CNavBarHeight = (screenHeight / 2220) * 120 + for (const { x, y } of returnImage.scanIterator(0, screenHeight - CNavBarHeight, screenWidth, CNavBarHeight)) + await returnImage.setPixelColor(0x616161ff, x, y) + const navBarImage = await Jimp.read('./android/navbar.png') + await navBarImage.resize(Jimp.AUTO, CNavBarHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(navBarImage, (screenWidth - navBarImage.bitmap.width) / 2, screenHeight - CNavBarHeight) + globalY += CNavBarHeight + } + { // Coupon Ding + const Padding = (screenHeight / 2220) * 65 + globalY += Padding + const CNavBarHeight = (screenHeight / 2220) * 503 + const CCouponEckeHeight = (screenHeight / 2220) * 16 + const CCouponLineWidth = Math.round((screenHeight / 2220) * 5) + const CCouponBoxWidth = (screenWidth / 1220) * 1090 + for (const { x, y } of returnImage.scanIterator((screenWidth - CCouponBoxWidth) / 2, globalY, CCouponBoxWidth, CCouponLineWidth)) + await returnImage.setPixelColor(0x5c5c5cff, x, y) + const lilaDingImage = await Jimp.read('./android/lilading.png') + await lilaDingImage.resize(Jimp.AUTO, CNavBarHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(lilaDingImage, ((screenWidth - CCouponBoxWidth) / 2) - lilaDingImage.bitmap.width, globalY) + const couponEckeImage = await Jimp.read('./android/kurvendingopenrechts.png') + await couponEckeImage.resize(Jimp.AUTO, CCouponEckeHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(couponEckeImage, ((screenWidth - CCouponBoxWidth) / 2) + CCouponBoxWidth, globalY) + for (const { x, y } of returnImage.scanIterator(((screenWidth - CCouponBoxWidth) / 2) + CCouponBoxWidth + couponEckeImage.bitmap.width - CCouponLineWidth, globalY + couponEckeImage.bitmap.height, CCouponLineWidth, lilaDingImage.bitmap.height)) + await returnImage.setPixelColor(0x5c5c5cff, x, y) + } + { // QRCodeBox + const CQrCodeBoxWidth = (screenWidth / 1220) * 996 + const CQrCodeBoxHeight = (screenHeight / 2220) * 1220 + const CQrCodeScanTextHeight = (screenHeight / 2220) * 168 + const CQrCodeCloseHeight = (screenHeight / 2220) * 45 + globalY = (screenHeight - CQrCodeBoxHeight) / 2 + for (const { x, y } of returnImage.scanIterator((screenWidth - CQrCodeBoxWidth) / 2, (screenHeight - CQrCodeBoxHeight) / 2, CQrCodeBoxWidth, CQrCodeBoxHeight)) + await returnImage.setPixelColor(0xffffffff, x, y) + const closeImage = await Jimp.read('./android/close.png') + await closeImage.resize(Jimp.AUTO, CQrCodeCloseHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(closeImage, + ((screenWidth + CQrCodeBoxWidth) / 2) - closeImage.bitmap.width * 2, + ((screenHeight - CQrCodeBoxHeight) / 2) + closeImage.bitmap.height + ) + const scanCodeImage = await Jimp.read('./android/code.png') + await scanCodeImage.resize(Jimp.AUTO, CQrCodeScanTextHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(scanCodeImage, + ((screenWidth - scanCodeImage.bitmap.width) / 2), + ((screenHeight - CQrCodeBoxHeight / 1.5) / 2) + ) + globalY += CQrCodeBoxHeight + } + { // Bottomshit + const Padding = (screenHeight / 2220) * 60 + globalY += Padding + const CBottomShitHeight = (screenHeight / 2220) * 103 + const CBottomShitLineWidth = Math.round((screenHeight / 2220) * 5) + const bottomShitImage = await Jimp.read('./android/bottomshit.png') + await bottomShitImage.resize(Jimp.AUTO, CBottomShitHeight, Jimp.RESIZE_BILINEAR) + await returnImage.composite(bottomShitImage, (screenWidth - bottomShitImage.bitmap.width) / 2, globalY) + globalY += CBottomShitHeight + for (const { x, y } of returnImage.scanIterator(0, globalY, screenWidth, CBottomShitLineWidth)) + await returnImage.setPixelColor(0x585858ff, x, y) + } + + await returnImage.writeAsync('test.png') +} +test() \ No newline at end of file diff --git a/renderservice/test.png b/renderservice/test.png new file mode 100644 index 0000000..38712b1 Binary files /dev/null and b/renderservice/test.png differ